Skip to content

Commit

Permalink
Fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki-YuXin committed Apr 26, 2024
1 parent d7d9032 commit c448b88
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.argThat
import org.mockito.ArgumentMatchers.contains
import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
Expand Down Expand Up @@ -197,26 +198,19 @@ class NativeAuthPublicClientApplicationKotlinTest : PublicClientApplicationAbstr

val result = application.signIn(username, password)

checkingSafeLogging()
checkSafeLogging()

assertTrue(result is SignInResult.Complete)
}

private fun checkingSafeLogging() {
private fun checkSafeLogging() {
val elementsToCheck = listOf("username", "password")
elementsToCheck.forEach { element ->
verifyLogContains(element)
verifyLogDoesNotContain(element)
}
}
// Custom matcher function to check if a list contains a certain element
private fun verifyLogContains(element: String) {
verify(externalLogger, never()).log(any(), any(), containsElement(element), eq(true))
}

private fun containsElement(element: String): String {
return argThat {
it.contains(element)
}
private fun verifyLogDoesNotContain(element: String) {
verify(externalLogger, never()).log(any(), any(), contains(element), eq(true))
}

/**
Expand Down

0 comments on commit c448b88

Please sign in to comment.