-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into dev-deploy
- Loading branch information
Showing
34 changed files
with
396 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
commons/src/main/java/pl/sknikod/kodemycommons/security/configuration/JwtConfiguration.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
kodemy-auth/src/test/groovy/pl/sknikod/kodemyauth/SuperclassSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package pl.sknikod.kodemyauth | ||
|
||
import com.github.tomakehurst.wiremock.WireMockServer | ||
import com.github.tomakehurst.wiremock.core.WireMockConfiguration | ||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration | ||
import org.springframework.test.context.ContextConfiguration | ||
import org.springframework.test.context.DynamicPropertyRegistry | ||
import org.springframework.test.context.DynamicPropertySource | ||
import org.testcontainers.containers.PostgreSQLContainer | ||
import org.testcontainers.junit.jupiter.Container | ||
import org.testcontainers.junit.jupiter.Testcontainers | ||
import spock.lang.Specification | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK) | ||
@ContextConfiguration(classes = KodemyAuthApplication.class) | ||
@ImportAutoConfiguration(value = TestChannelBinderConfiguration.class) | ||
@Testcontainers | ||
abstract class SuperclassSpec extends Specification { | ||
@Container | ||
private static final PostgreSQLContainer<?> DATASOURCE | ||
private static final WireMockServer WIREMOCK | ||
private static int WIREMOCK_PORT = 9999 | ||
|
||
static { | ||
DATASOURCE = new PostgreSQLContainer<>("postgres:14.1-alpine") | ||
WIREMOCK = new WireMockServer(WireMockConfiguration.options().port(WIREMOCK_PORT)) | ||
} | ||
|
||
@DynamicPropertySource | ||
private static void containerProperties(DynamicPropertyRegistry registry) { | ||
registry.add("spring.datasource.url", DATASOURCE::getJdbcUrl) | ||
registry.add("spring.datasource.username", DATASOURCE::getUsername) | ||
registry.add("spring.datasource.password", DATASOURCE::getPassword) | ||
|
||
final String wiremockBaseUrl = "http://localhost:${WIREMOCK_PORT}" | ||
Map.of( | ||
"service.baseUrl.gateway", "${wiremockBaseUrl}/gateway", | ||
"security.oauth2.client.registration.github.tokenUri", "${wiremockBaseUrl}/login/oauth/access_token", | ||
"security.oauth2.client.registration.github.authorizationUri", "${wiremockBaseUrl}/login/oauth/authorize", | ||
"security.oauth2.client.registration.github.userInfoEndpoint.uri", "${wiremockBaseUrl}/user", | ||
"eureka.client.enabled", false, | ||
).forEach { | ||
key, value -> registry.add(key, { value }) | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
kodemy-auth/src/test/groovy/pl/sknikod/kodemyauth/factory/RefreshTokenFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package pl.sknikod.kodemyauth.factory; | ||
|
||
import pl.sknikod.kodemyauth.infrastructure.database.RefreshToken; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.UUID; | ||
|
||
public class RefreshTokenFactory { | ||
public static RefreshToken create(UUID token, UUID bearerJti) { | ||
RefreshToken refreshToken = new RefreshToken( | ||
token, | ||
bearerJti, | ||
LocalDateTime.now(), | ||
UserFactory.create() | ||
); | ||
refreshToken.setId(1L); | ||
return refreshToken; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
kodemy-auth/src/test/groovy/pl/sknikod/kodemyauth/factory/RoleFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package pl.sknikod.kodemyauth.factory; | ||
|
||
import pl.sknikod.kodemyauth.infrastructure.database.Permission; | ||
import pl.sknikod.kodemyauth.infrastructure.database.Role; | ||
|
||
import java.util.Set; | ||
|
||
public class RoleFactory { | ||
public static Role create() { | ||
Role role = new Role(); | ||
role.setId(1L); | ||
role.setPermissions(Set.of(new Permission("PERMISSION"))); | ||
return role; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
kodemy-auth/src/test/groovy/pl/sknikod/kodemyauth/factory/UserFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package pl.sknikod.kodemyauth.factory; | ||
|
||
import pl.sknikod.kodemyauth.infrastructure.database.User; | ||
|
||
public class UserFactory { | ||
public static User create(Long userId) { | ||
User user = new User( | ||
"username", | ||
"[email protected]", | ||
null, | ||
RoleFactory.create() | ||
); | ||
user.setId(userId); | ||
return user; | ||
} | ||
|
||
public static User create() { | ||
return create(1L); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...est/groovy/pl/sknikod/kodemyauth/infrastructure/module/auth/AccessTokenServiceSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package pl.sknikod.kodemyauth.infrastructure.module.auth | ||
|
||
import spock.lang.Specification | ||
|
||
class AccessTokenServiceSpec extends Specification { | ||
def TOKEN = "eyJhbGciOiJIUzM4NCJ9.eyJpc3MiOiJwbC5za25pa29kLmtvZGVteSIsImp0aSI6ImQxMWI0MDhkLWYwNTMtNDIwMC04YjFkLTE2ODRkYTg4NzEyNCIsInN1YiI6IkthcnRWZW4iLCJpYXQiOjE3MzMyNjU0MDUsImV4cCI6MTczMzMwODYwNSwic3RhdGUiOjgsImF1dGhvcml0aWVzIjpbXSwiaWQiOjF9.qt751MNLNOlLqUkattm3bH0BJtVsmBQBk3g5WTcwBHJTrWNVwhNALv0TQRpRfQQJ" | ||
|
||
def accessTokenService = new AccessTokenService() | ||
|
||
def "should get access token"() { | ||
when: | ||
def result = accessTokenService.getAccessToken("Bearer " + TOKEN) | ||
|
||
then: | ||
result == TOKEN | ||
} | ||
} |
Oops, something went wrong.