Skip to content

Commit

Permalink
testcontainers dependencies are added
Browse files Browse the repository at this point in the history
  • Loading branch information
musab.bozkurt committed Feb 3, 2024
1 parent 854aa53 commit 21c7597
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 15 deletions.
22 changes: 22 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<properties>
<java.version>21</java.version>
<org.testcontainers.version>1.19.4</org.testcontainers.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -63,6 +64,27 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${org.testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mariadb</artifactId>
<version>${org.testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${org.testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-docker-compose</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spring:
baseline-on-migrate: true
schemas: oauth2_authorization_server
table: schema_version
validate-on-migrate: false
validate-on-migrate: true

jpa:
properties:
Expand Down
25 changes: 11 additions & 14 deletions src/main/resources/db/migration/V1_0001__init_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,28 @@ create table if not exists oauth2_authorization_server.users_authorities
);

alter table oauth2_authorization_server.authorities
drop index if exists UK_q0u5f2cdlshec8tlh6818bhbk;

drop index if exists idx__authorities_authority;

alter table oauth2_authorization_server.authorities
add constraint UK_q0u5f2cdlshec8tlh6818bhbk unique (authority);

add constraint idx__authorities_authority unique (authority);

alter table oauth2_authorization_server.users
drop index if exists UK_r43af9ap4edm43mmtq01oddj6;

drop index if exists idx__users_username;

alter table oauth2_authorization_server.users
add constraint UK_r43af9ap4edm43mmtq01oddj6 unique (username);
add constraint idx__users_username unique (username);

alter table oauth2_authorization_server.users_authorities
drop constraint if exists users_authorities_authorities_id__authorities_id;

alter table oauth2_authorization_server.users_authorities
add constraint FKmfxncv8ke1jjgna64c8kclry5
foreign key (authorities_id)
references authorities (id);
add constraint users_authorities_authorities_id__authorities_id foreign key (authorities_id) references oauth2_authorization_server.authorities (id);

alter table oauth2_authorization_server.users_authorities
drop constraint if exists users_authorities_users_id__users_id;

alter table oauth2_authorization_server.users_authorities
add constraint FK2cmfwo8tbjcpmltse0rh5ir0t
foreign key (users_id)
references users (id);
add constraint users_authorities_users_id__users_id foreign key (users_id) references oauth2_authorization_server.users (id);

INSERT INTO oauth2_authorization_server.authorities(authority)
VALUES ('ROLE_USER');
Expand Down Expand Up @@ -148,7 +145,7 @@ VALUES ('abbc70f1-fb59-4b42-b1e4-c52fa0080bea', 'refresh_token,client_credential
'client_secret_basic', 'client', null, 'abbc70f1-fb59-4b42-b1e4-c52fa0080bea',
'$2a$10$lcGI9Fp6GLfk7wjyOK0VqORQqMtsQRoC3J7i/V023SgQv9JZLZ01K', null,
'{"@class":"java.util.Collections$UnmodifiableMap","settings.client.require-proof-key":true,"settings.client.require-authorization-consent":true}',
'http://insomnia,http://127.0.0.1:8080/login/oauth2/code/client', 'read,openid,profile',
'https://insomnia,http://127.0.0.1:8080/login/oauth2/code/client', 'read,openid,profile',
'{"@class":"java.util.Collections$UnmodifiableMap","settings.token.reuse-refresh-tokens":true,
"settings.token.id-token-signature-algorithm":["org.springframework.security.oauth2.jose.jws.SignatureAlgorithm","RS256"],
"settings.token.access-token-time-to-live":["java.time.Duration",86400.000000000],
Expand Down
42 changes: 42 additions & 0 deletions src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
server:
port: '9000'

spring:
datasource:
url: 'jdbc:tc:mariadb://localhost:3306/oauth2_authorization_server'
username: mb_test
password: 'test'
driver-class-name: org.testcontainers.jdbc.ContainerDatabaseDriver

flyway:
enabled: true
baseline-version: 0
baseline-on-migrate: true
schemas: oauth2_authorization_server
table: schema_version
validate-on-migrate: true

jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MariaDBDialect
format_sql: true
default_schema: oauth2_authorization_server
defer-datasource-initialization: false # https://stackoverflow.com/a/69235286 -> https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html
hibernate:
ddl-auto: validate
generate-ddl: false
show-sql: true
database-platform: org.hibernate.dialect.MariaDBDialect

logging:
level:
org.springframework.security: trace

springdoc:
api-docs:
path: /v3/api-docs # http://localhost:9000/v3/api-docs
swagger-ui:
path: /swagger-ui.html # http://localhost:9000/swagger-ui/index.html
csrf:
enabled: true

0 comments on commit 21c7597

Please sign in to comment.