Skip to content

Commit 53ceb13

Browse files
committed
release: v0.3.5-rc1 fix supabase-kt
1 parent 12f52b3 commit 53ceb13

File tree

8 files changed

+35
-44
lines changed

8 files changed

+35
-44
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ jobs:
99
publish:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1313
- name: Set up Java
14-
uses: actions/setup-java@v3
14+
uses: actions/setup-java@v4
1515
with:
1616
java-version: '17'
1717
distribution: 'adopt'

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ out/
3636
### VS Code ###
3737
.vscode/
3838
/src/test/resources/dev.env
39-
/node_modules
39+
/node_modules
40+
/src/test/resources/test.env
41+
/src/test/resources/test.properties

build.gradle.kts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ plugins {
77
kotlin("jvm") version "1.9.22"
88
kotlin("plugin.spring") version "1.9.22"
99
kotlin("plugin.jpa") version "1.9.22"
10-
1110
id("maven-publish")
1211
id("org.jreleaser") version "1.13.0"
1312
id("signing")
1413
}
1514

1615
group = "de.tschuehly"
17-
version = "0.3.4"
16+
version = "0.3.5-RC1"
1817
java.sourceCompatibility = JavaVersion.VERSION_17
1918

2019
repositories {
@@ -36,11 +35,11 @@ dependencies {
3635
implementation("jakarta.annotation:jakarta.annotation-api:2.1.1")
3736
implementation("com.auth0:java-jwt:4.3.0")
3837

39-
implementation("io.github.jan-tennert.supabase:gotrue-kt:2.0.4")
40-
runtimeOnly("io.ktor:ktor-client-java:2.3.7")
41-
testRuntimeOnly("io.ktor:ktor-client-java:2.3.7")
42-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
43-
testImplementation("io.ktor:ktor-client-mock:2.3.6")
38+
implementation("io.github.jan-tennert.supabase:gotrue-kt:2.6.0")
39+
runtimeOnly("io.ktor:ktor-client-java:2.3.12")
40+
testRuntimeOnly("io.ktor:ktor-client-java:2.3.12")
41+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.0")
42+
testImplementation("io.ktor:ktor-client-mock:2.3.12")
4443

4544

4645
implementation("org.jetbrains.kotlin:kotlin-reflect")

src/main/kotlin/de/tschuehly/htmx/spring/supabase/auth/security/SupabaseSecurityConfig.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class SupabaseSecurityConfig(
2828
val logger: Logger = LoggerFactory.getLogger(SupabaseSecurityConfig::class.java)
2929

3030
@Bean
31-
@ConditionalOnMissingBean
3231
fun filterChain(
3332
http: HttpSecurity,
3433
supabaseJwtFilter: SupabaseJwtFilter,

src/main/kotlin/de/tschuehly/htmx/spring/supabase/auth/service/SupabaseUserServiceGoTrueImpl.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import io.github.jan.supabase.exceptions.RestException
1616
import io.github.jan.supabase.gotrue.Auth
1717
import io.github.jan.supabase.gotrue.providers.builtin.Email
1818
import io.github.jan.supabase.gotrue.providers.builtin.OTP
19+
import io.github.jan.supabase.gotrue.user.UserInfo
1920
import jakarta.servlet.http.HttpServletRequest
2021
import jakarta.servlet.http.HttpServletResponse
2122
import kotlinx.coroutines.CoroutineScope
@@ -176,7 +177,7 @@ class SupabaseUserServiceGoTrueImpl(
176177
throw UnknownSupabaseException()
177178
}
178179

179-
private fun emailConfirmationEnabled(user: Email.Result?): Boolean {
180+
private fun emailConfirmationEnabled(user: UserInfo?): Boolean {
180181
return user != null
181182
}
182183
}

src/test/kotlin/de/tschuehly/htmx/spring/supabase/auth/application/TestApplication.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerA
88
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
99
import org.springframework.boot.runApplication
1010

11-
@SpringBootApplication(
12-
exclude = [
13-
DataSourceAutoConfiguration::class,
14-
DataSourceTransactionManagerAutoConfiguration::class,
15-
HibernateJpaAutoConfiguration::class
16-
],
17-
)
18-
@ImportAutoConfiguration(SupabaseAutoConfiguration::class)
19-
11+
@SpringBootApplication
2012
class TestApplication {
2113

2214
}

src/test/kotlin/de/tschuehly/htmx/spring/supabase/auth/test/SupabaseHtmxTests.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith
1313
import org.springframework.boot.test.context.SpringBootTest
1414
import org.springframework.boot.test.web.server.LocalServerPort
1515
import org.springframework.context.annotation.Import
16+
import org.springframework.context.annotation.PropertySource
1617
import org.springframework.test.context.TestPropertySource
1718
import org.springframework.test.context.junit.jupiter.SpringExtension
1819
import org.springframework.web.context.WebApplicationContext
@@ -23,9 +24,7 @@ import org.springframework.web.context.WebApplicationContext
2324
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
2425
properties = ["debug=org.springframework.security"],
2526
)
26-
@TestPropertySource(
27-
properties = ["SUPABASE_PROJECT_ID=", "SUPABASE_ANON_KEY=", "SUPABASE_DATABASE_PW=", "SUPABASE_JWT_SECRET="]
28-
)
27+
@PropertySource(value = ["classpath:/test.properties"], ignoreResourceNotFound = true)
2928
@Import(GoTrueMockConfiguration::class)
3029
class SupabaseHtmxTests {
3130

src/test/kotlin/de/tschuehly/htmx/spring/supabase/auth/test/mock/GoTrueMock.kt

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package de.tschuehly.htmx.spring.supabase.auth.test.mock
22

3-
import io.github.jan.supabase.gotrue.providers.builtin.Email
4-
import io.github.jan.supabase.gotrue.providers.builtin.Phone
53
import io.github.jan.supabase.gotrue.user.UserInfo
64
import io.github.jan.supabase.gotrue.user.UserSession
75
import io.ktor.client.engine.mock.*
@@ -91,9 +89,9 @@ class GoTrueMock {
9189
val token = authorizationHeader.substringAfter("Bearer ")
9290
if (token != VALID_ACCESS_TOKEN) return respondUnauthorized()
9391
return when (request.method) {
94-
HttpMethod.Get -> respond(UserInfo(aud = "", id = "userid"))
92+
HttpMethod.Get -> respondJson(UserInfo(aud = "", id = "userid"))
9593
HttpMethod.Put -> {
96-
respond(
94+
respondJson(
9795
UserInfo(
9896
aud = "",
9997
id = "userid",
@@ -118,25 +116,18 @@ class GoTrueMock {
118116
return when {
119117
body.containsKey("email") -> {
120118
respond(
121-
Email.Result(
122-
"uuid",
123-
body["email"]!!.jsonPrimitive.content,
124-
Clock.System.now(),
125-
Clock.System.now(),
126-
Clock.System.now()
127-
)
119+
sampleUserObject(body["email"]!!.jsonPrimitive.content),
120+
HttpStatusCode.OK,
121+
headersOf("Content-Type" to listOf("application/json"))
122+
128123
)
129124
}
130125

131126
body.containsKey("phone") -> {
132127
respond(
133-
Phone.Result(
134-
"uuid",
135-
body["phone"]!!.jsonPrimitive.content,
136-
Clock.System.now(),
137-
Clock.System.now(),
138-
Clock.System.now()
139-
)
128+
sampleUserObject(body["phone"]!!.jsonPrimitive.content),
129+
HttpStatusCode.OK,
130+
headersOf("Content-Type" to listOf("application/json"))
140131
)
141132
}
142133

@@ -188,15 +179,15 @@ class GoTrueMock {
188179
}
189180
}
190181

191-
private inline fun <reified T> MockRequestHandleScope.respond(data: T): HttpResponseData {
182+
private inline fun <reified T> MockRequestHandleScope.respondJson(data: T): HttpResponseData {
192183
return respond(
193184
Json.encodeToString(data),
194185
HttpStatusCode.OK,
195186
headersOf("Content-Type" to listOf("application/json"))
196187
)
197188
}
198189

199-
private fun MockRequestHandleScope.respondValidSession() = respond(
190+
private fun MockRequestHandleScope.respondValidSession() = respondJson(
200191
UserSession(
201192
NEW_ACCESS_TOKEN,
202193
"refresh_token",
@@ -233,5 +224,13 @@ class GoTrueMock {
233224
const val VALID_VERIFY_TOKEN = "valid_verify_token"
234225
}
235226

227+
private fun sampleUserObject(email: String? = null, phone: String? = null) = """
228+
{
229+
"id": "id",
230+
"aud": "aud",
231+
"email": "$email",
232+
"phone": "$phone"
233+
}
234+
""".trimIndent()
236235

237236
}

0 commit comments

Comments
 (0)