-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from myndocs/release/0.3.1
Release/0.3.1
- Loading branch information
Showing
15 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
oauth2-server-core/src/main/java/nl/myndocs/oauth2/request/CallContextHeader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package nl.myndocs.oauth2.request | ||
|
||
fun CallContext.headerCaseInsensitive(key: String) = | ||
headers | ||
.filter { it.key.equals(key, true) } | ||
.values | ||
.firstOrNull() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
oauth2-server-core/src/test/java/nl/myndocs/oauth2/request/auth/BasicAuthorizerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package nl.myndocs.oauth2.request.auth | ||
|
||
import io.mockk.every | ||
import io.mockk.mockk | ||
import nl.myndocs.oauth2.request.CallContext | ||
import org.hamcrest.CoreMatchers.* | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.junit.jupiter.api.Test | ||
import java.util.* | ||
|
||
internal class BasicAuthorizerTest { | ||
|
||
@Test | ||
fun `test authorization head is case insensitive with all uppercase input`() { | ||
`test authorization head is case insensitive with input`( | ||
"AUTHORIZATION" | ||
) | ||
} | ||
|
||
@Test | ||
fun `test authorization head is case insensitive with all lowercase input`() { | ||
`test authorization head is case insensitive with input`( | ||
"authorization" | ||
) | ||
} | ||
|
||
private fun `test authorization head is case insensitive with input`(authorizationKeyName: String) { | ||
val callContext = mockk<CallContext>() | ||
val username = "test" | ||
val password = "test-password" | ||
|
||
val testCredentials = Base64.getEncoder().encodeToString("$username:$password".toByteArray()) | ||
|
||
every { callContext.headers } returns mapOf(authorizationKeyName to "basic $testCredentials") | ||
val credentials = BasicAuthorizer(callContext) | ||
.extractCredentials() | ||
|
||
assertThat(credentials, `is`(notNullValue())) | ||
assertThat(credentials!!.username, `is`(equalTo(username))) | ||
assertThat(credentials.password, `is`(equalTo(password))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters