-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove
com.google.*
dependent code from the `jkube-kit-bu…
…ild-api` module Signed-off-by: Marc Nuri <[email protected]>
- Loading branch information
Showing
16 changed files
with
343 additions
and
160 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
52 changes: 52 additions & 0 deletions
52
jkube-kit/build/api/src/test/java/org/eclipse/jkube/kit/build/api/auth/AuthConfigTest.java
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,52 @@ | ||
/* | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.kit.build.api.auth; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import org.eclipse.jkube.kit.common.KitLogger; | ||
import org.eclipse.jkube.kit.common.util.Serialization; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Base64; | ||
import java.util.Map; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.entry; | ||
|
||
class AuthConfigTest { | ||
|
||
@Test | ||
void simpleConstructor() { | ||
AuthConfig config = AuthConfig.builder() | ||
.username("roland") | ||
.password("#>secrets??") | ||
.email("[email protected]") | ||
.build(); | ||
// Since Base64.decodeBase64 handles URL-safe encoding, must explicitly check | ||
// the correct characters are used | ||
assertThat(config.toHeaderValue(new KitLogger.SilentLogger())) | ||
.isEqualTo("eyJ1c2VybmFtZSI6InJvbGFuZCIsInBhc3N3b3JkIjoiIz5zZWNyZXRzPz8iLCJlbWFpbCI6InJvbGFuZEBqb2xva2lhLm9yZyJ9"); | ||
|
||
String header = new String(Base64.getDecoder().decode(config.toHeaderValue(new KitLogger.SilentLogger()))); | ||
|
||
final Map<String, Object> result = Serialization.unmarshal(header, new TypeReference<Map<String, Object>>() { | ||
}); | ||
assertThat(result) | ||
.containsOnly( | ||
entry("username", "roland"), | ||
entry("password", "#>secrets??"), | ||
entry("email", "[email protected]") | ||
); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -14,16 +14,17 @@ | |
package org.eclipse.jkube.kit.build.api.auth; | ||
|
||
import java.util.Base64; | ||
import java.util.Map; | ||
|
||
import com.google.gson.JsonObject; | ||
import org.eclipse.jkube.kit.common.JsonFactory; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import org.eclipse.jkube.kit.common.util.Serialization; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.entry; | ||
|
||
/** | ||
* @author roland | ||
* @since 30.07.14 | ||
*/ | ||
class RegistryAuthTest { | ||
|
||
|
@@ -53,11 +54,13 @@ private void check(RegistryAuth config) { | |
|
||
String header = new String(Base64.getDecoder().decode(config.toHeaderValue())); | ||
|
||
JsonObject data = JsonFactory.newJsonObject(header); | ||
assertThat(data) | ||
.returns("roland", d -> d.get("username").getAsString()) | ||
.returns("#>secrets??", d -> d.get("password").getAsString()) | ||
.returns("[email protected]", d -> d.get("email").getAsString()) | ||
.returns(false, d -> d.has("auth")); | ||
final Map<String, Object> result = Serialization.unmarshal(header, new TypeReference<Map<String, Object>>() { | ||
}); | ||
assertThat(result) | ||
.containsOnly( | ||
entry("username", "roland"), | ||
entry("password", "#>secrets??"), | ||
entry("email", "[email protected]") | ||
); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.