Skip to content

Commit 7a3089a

Browse files
committed
tests: adds auth service integration tests
1 parent 381b0d6 commit 7a3089a

File tree

7 files changed

+883
-20
lines changed

7 files changed

+883
-20
lines changed

auth-service/auth-service-main/auth-main-app/src/main/resources/application.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ spring:
3434
registration:
3535
google-idp:
3636
provider: google
37-
client-id: 558968372674-jkalu209g122k7iua1eolr1aplkipl6l.apps.googleusercontent.com
38-
client-secret: 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
37+
client-id: ${GOOGLE_CLIENT_ID}
38+
client-secret: ${GOOGLE_CLIENT_SECRET}
3939
scope: openid, https://www.googleapis.com/auth/userinfo.profile, https://www.googleapis.com/auth/userinfo.email
4040
client-name: Sign in with Google
4141
provider:

auth-service/auth-service-web/auth-web-lib/.classpath

+766-6
Large diffs are not rendered by default.

auth-service/auth-service-web/auth-web-lib/.project

+10-12
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,27 @@
22
<projectDescription>
33
<name>auth-web-lib</name>
44
<comment></comment>
5-
<projects>
6-
</projects>
5+
<projects/>
6+
<natures>
7+
<nature>org.eclipse.jdt.core.javanature</nature>
8+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
9+
</natures>
710
<buildSpec>
811
<buildCommand>
912
<name>org.eclipse.jdt.core.javabuilder</name>
10-
<arguments>
11-
</arguments>
13+
<arguments/>
1214
</buildCommand>
1315
<buildCommand>
1416
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15-
<arguments>
16-
</arguments>
17+
<arguments/>
1718
</buildCommand>
1819
</buildSpec>
19-
<natures>
20-
<nature>org.eclipse.jdt.core.javanature</nature>
21-
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22-
</natures>
20+
<linkedResources/>
2321
<filteredResources>
2422
<filter>
25-
<id>1706213651540</id>
26-
<name></name>
23+
<id>1</id>
2724
<type>30</type>
25+
<name/>
2826
<matcher>
2927
<id>org.eclipse.core.resources.regexFilterMatcher</id>
3028
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>

auth-service/auth-service-web/auth-web-lib/build.gradle.kts

+60
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,64 @@ dependencies {
1515
implementation("org.springframework.security:spring-security-oauth2-authorization-server")
1616
implementation("org.springframework.security:spring-security-cas")
1717
implementation("org.springframework:spring-jdbc")
18+
}
19+
20+
sourceSets {
21+
create("integrationTest") {
22+
compileClasspath += sourceSets.main.get().output
23+
runtimeClasspath += sourceSets.main.get().output
24+
}
25+
}
26+
27+
val integrationTestImplementation by configurations.getting {
28+
extendsFrom(configurations.implementation.get())
29+
}
30+
val integrationTestRuntimeOnly by configurations.getting
31+
32+
configurations["integrationTestRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get())
33+
34+
val integrationTest = task<Test>("integrationTest") {
35+
description = "Runs integration tests."
36+
group = "verification"
37+
38+
testClassesDirs = sourceSets["integrationTest"].output.classesDirs
39+
classpath = sourceSets["integrationTest"].runtimeClasspath
40+
shouldRunAfter("test")
41+
42+
useJUnitPlatform()
43+
44+
testLogging {
45+
events("passed")
46+
}
47+
48+
finalizedBy("jacocoIntegrationTestReport")
49+
}
50+
51+
dependencies {
52+
integrationTestImplementation(platform("com.codedifferently.studycrm.platform:java-test-platform"))
53+
integrationTestImplementation("org.junit.jupiter:junit-jupiter")
54+
integrationTestImplementation("org.mockito:mockito-core")
55+
integrationTestImplementation("org.springframework.boot:spring-boot-starter-test")
56+
integrationTestImplementation("org.springframework.security:spring-security-test")
57+
integrationTestRuntimeOnly("com.h2database:h2")
58+
integrationTestRuntimeOnly("org.junit.platform:junit-platform-launcher")
59+
}
60+
61+
tasks.register<JacocoReport>("jacocoIntegrationTestReport") {
62+
executionData(tasks.named("integrationTest").get())
63+
sourceSets(sourceSets["integrationTest"])
64+
65+
reports {
66+
xml.required.set(true)
67+
html.required.set(true)
68+
}
69+
}
70+
71+
tasks.jacocoTestReport {
72+
dependsOn("jacocoIntegrationTestReport")
73+
}
74+
75+
tasks.check {
76+
dependsOn(integrationTest)
77+
dependsOn("jacocoIntegrationTestReport")
1878
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.codedifferently.studycrm.auth.web;
2+
3+
import org.springframework.boot.autoconfigure.SpringBootApplication;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
@SpringBootApplication(scanBasePackages = "com.codedifferently.studycrm.auth")
7+
@Configuration
8+
public class TestConfiguration {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.codedifferently.studycrm.auth.web.config;
2+
3+
import com.codedifferently.studycrm.auth.web.TestConfiguration;
4+
import org.junit.jupiter.api.Test;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.ContextConfiguration;
7+
8+
@SpringBootTest
9+
@ContextConfiguration(classes = {TestConfiguration.class})
10+
class DefaultSecurityConfigTest {
11+
12+
@Test
13+
void testDefaultSecurityConfig_loads() throws Exception {
14+
System.out.println(getClass());
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
spring:
2+
datasource:
3+
url: jdbc:h2:mem:mydb
4+
username: sa
5+
password: password
6+
driverClassName: org.h2.Driver
7+
jpa:
8+
spring.jpa.database-platform: org.hibernate.dialect.H2Dialect
9+
security:
10+
oauth2:
11+
client:
12+
registration:
13+
google-idp:
14+
provider: google
15+
client-id: ${GOOGLE_CLIENT_ID}
16+
client-secret: ${GOOGLE_CLIENT_SECRET}
17+
scope: openid, https://www.googleapis.com/auth/userinfo.profile, https://www.googleapis.com/auth/userinfo.email
18+
client-name: Sign in with Google
19+
provider:
20+
google:
21+
user-name-attribute: email

0 commit comments

Comments
 (0)