Skip to content

Commit 0f65601

Browse files
committed
chore: fix wildcard import, remove unused code
1 parent 51760a6 commit 0f65601

File tree

2 files changed

+2
-47
lines changed

2 files changed

+2
-47
lines changed

src/main/kotlin/no/nav/security/mock/oauth2/token/OAuth2TokenCallback.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import no.nav.security.mock.oauth2.extensions.replaceValues
99
import no.nav.security.mock.oauth2.extensions.scopesWithoutOidcScopes
1010
import no.nav.security.mock.oauth2.extensions.tokenExchangeGrantOrNull
1111
import java.time.Duration
12-
import java.util.*
12+
import java.util.UUID
1313

1414
interface OAuth2TokenCallback {
1515
fun issuerId(): String

src/test/kotlin/no/nav/security/mock/oauth2/extensions/TemplateTest.kt

+1-46
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test
66

77
class TemplateTest {
88
@Test
9-
fun `template values in map should be replaced`() {
9+
fun `template values in map should be replaced`() {
1010
val templates =
1111
mapOf(
1212
"templateVal1" to "val1",
@@ -25,49 +25,4 @@ class TemplateTest {
2525
println(it)
2626
}
2727
}
28-
29-
// Example usage
30-
fun main() {
31-
val jsonData: Map<String, Any> =
32-
mapOf(
33-
"myobject" to
34-
mapOf(
35-
"participantId" to "\${someTemlateVal}",
36-
"actAs" to listOf("\${templateVal1}, \${templateVal2}"),
37-
"readAs" to listOf("\${templateVal2}"),
38-
),
39-
"myobject2" to "someValue",
40-
)
41-
42-
val templates =
43-
mapOf(
44-
"someTemlateVal" to "participant123",
45-
"templateVal1" to "actor123",
46-
"templateVal2" to "reader123",
47-
)
48-
49-
val replacedData = jsonData.replaceValues(templates)
50-
println(replacedData)
51-
}
52-
53-
/*fun replaceTemplates(data: Map<String, Any>, templates: Map<String, String>): Map<String, Any> {
54-
fun replaceValue(value: Any): Any {
55-
return when (value) {
56-
is String -> replaceTemplateString(value, templates)
57-
is List<*> -> value.map { replaceValue(it) }
58-
is Map<*, *> -> value.mapValues { replaceValue(it.value) }
59-
else -> value
60-
}
61-
}
62-
63-
fun replaceTemplateString(value: String, templates: Map<String, String>): String {
64-
val regex = Regex("""\$\{(\w+)\}""")
65-
return regex.replace(value) { matchResult ->
66-
val key = matchResult.groupValues[1]
67-
templates[key] ?: matchResult.value
68-
}
69-
}
70-
71-
return data.mapValues { replaceValue(it.value) }
72-
}*/
7328
}

0 commit comments

Comments
 (0)