54 lines
1.4 KiB
Kotlin
54 lines
1.4 KiB
Kotlin
package com.rssuper.services
|
|
|
|
import org.junit.Assert.assertEquals
|
|
import org.junit.Assert.assertNotNull
|
|
import org.junit.Assert.assertTrue
|
|
import org.junit.Test
|
|
|
|
class HTTPAuthCredentialsTest {
|
|
|
|
@Test
|
|
fun testBasicAuthCredentials() {
|
|
val auth = HTTPAuthCredentials("username", "password")
|
|
val credentials = auth.toCredentials()
|
|
|
|
assertNotNull(credentials)
|
|
assertTrue(credentials.startsWith("Basic "))
|
|
}
|
|
|
|
@Test
|
|
fun testBasicAuthCredentialsWithSpecialChars() {
|
|
val auth = HTTPAuthCredentials("user@domain", "pass!@#")
|
|
val credentials = auth.toCredentials()
|
|
|
|
assertNotNull(credentials)
|
|
assertTrue(credentials.startsWith("Basic "))
|
|
}
|
|
|
|
@Test
|
|
fun testUsernameAndPassword() {
|
|
val auth = HTTPAuthCredentials("testuser", "testpass")
|
|
|
|
assertEquals("testuser", auth.username)
|
|
assertEquals("testpass", auth.password)
|
|
}
|
|
|
|
@Test
|
|
fun testEmptyUsername() {
|
|
val auth = HTTPAuthCredentials("", "password")
|
|
val credentials = auth.toCredentials()
|
|
|
|
assertNotNull(credentials)
|
|
assertTrue(credentials.startsWith("Basic "))
|
|
}
|
|
|
|
@Test
|
|
fun testEmptyPassword() {
|
|
val auth = HTTPAuthCredentials("username", "")
|
|
val credentials = auth.toCredentials()
|
|
|
|
assertNotNull(credentials)
|
|
assertTrue(credentials.startsWith("Basic "))
|
|
}
|
|
}
|