mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
35 lines
930 B
Kotlin
35 lines
930 B
Kotlin
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
|
package com.intellij.credentialStore
|
|
|
|
import org.assertj.core.api.Assertions.assertThat
|
|
import org.junit.Test
|
|
|
|
class CredentialSerializeTest {
|
|
@Test
|
|
fun join() {
|
|
test("foo", "pass", "foo@pass")
|
|
test("foo", "\\pass@", "foo@\\pass@")
|
|
test("foo@", "pass", "foo\\@@pass")
|
|
test("\\foo@", "pass", "\\\\foo\\@@pass")
|
|
test("\\foo\\", "pass", "\\\\foo\\\\@pass")
|
|
test("foo", "", "foo@")
|
|
}
|
|
|
|
@Test
|
|
fun emptyUser() {
|
|
test("", "pass", "@pass")
|
|
}
|
|
|
|
@Test
|
|
fun nullPassword() {
|
|
test("foo", null, "foo")
|
|
test(null, "foo@", "@foo@")
|
|
}
|
|
|
|
private fun test(u: String?, p: String?, joined: String) {
|
|
val pass = p?.let(::OneTimeString)
|
|
assertThat(joinData(u, pass)).isEqualTo(joined.toByteArray())
|
|
assertThat(splitData(joined)).isEqualTo(Credentials(u, pass))
|
|
}
|
|
}
|