Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#22 Add container support for Integration tests #103

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions build.gradle.kts
Expand Up @@ -5,13 +5,14 @@ plugins {
kotlin("kapt") version kotlinVersion
kotlin("plugin.allopen") version kotlinVersion
id("com.github.johnrengelman.shadow") version "7.1.1"
id("io.micronaut.application") version "3.4.0"
id("io.micronaut.application") version "3.6.0"
id("io.micronaut.test-resources") version "3.6.0"

// /****** Additional tooling *****/
// // OpenAPI code generation
// id("org.openapi.generator") version "4.3.1"
// Code formatting
id("com.diffplug.spotless") version "6.5.1"
id("com.diffplug.spotless") version "6.11.0"
}

group = "com.faforever"
Expand Down
7 changes: 7 additions & 0 deletions src/test/kotlin/com/faforever/userservice/ApplicationIT.kt
Expand Up @@ -13,6 +13,7 @@ import com.faforever.userservice.hydra.RevokeRefreshTokensRequest
import com.faforever.userservice.security.FafRole
import com.faforever.userservice.security.FafUserAuthentication
import com.faforever.userservice.security.OAuthScope
import io.micronaut.context.annotation.Value
import io.micronaut.http.HttpStatus
import io.micronaut.http.client.exceptions.HttpClientResponseException
import io.micronaut.runtime.EmbeddedApplication
Expand Down Expand Up @@ -81,6 +82,12 @@ class ApplicationIT : TestPropertyProvider {
mockServer.reset()
}

@Value("\${hydra.host}")
private val hydraHost: String? = null

@Value("\${hydra.port}")
private val hydraPort: String? = null

@Mock
@get:MockBean(UserRepository::class)
lateinit var userRepository: UserRepository
Expand Down
23 changes: 23 additions & 0 deletions src/test/resources/application-test.yml
@@ -0,0 +1,23 @@
test-resources:
containers:
mariadb:
image-name: mariadb:10.6
network: faf
network-aliases: faf-db
ory-hydra:
image-name: oryd/hydra:v1.11.7
network: faf
network-aliases: faf-ory-hydra
command: serve all -c /hydra.yaml --dangerous-force-http
hostnames:
- hydra.host
exposed-ports:
- hydra.port: 4445
ro-fs-bind:
- classpath:/hydra.yaml: /hydra.yaml

r2dbc:
datasources:
default:
db-type: mariadb
dialect: MYSQL
19 changes: 19 additions & 0 deletions src/test/resources/hydra.yaml
@@ -0,0 +1,19 @@
# Customize this to your need
dsn: mysql://hydra:banana@tcp(faf-db:3306)/hydra
secrets:
system:
- bananapineapplepizza
urls:
self:
issuer: http://faf-ory-hydra:4444
public: http://localhost:4444
login: http://localhost:8080/oauth2/login
consent: http://localhost:8080/oauth2/consent

# Static configuration
strategies:
access_token: jwt

oauth2:
client_credentials:
default_grant_allowed_scope: true