Skip to content

Commit

Permalink
#22 Add container support for Integration tests WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bukajsytlos committed Sep 15, 2022
1 parent 72d5ab7 commit 121bf59
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
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

0 comments on commit 121bf59

Please sign in to comment.