-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into pr/issue1197
- Loading branch information
Showing
7 changed files
with
118 additions
and
50 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
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
48 changes: 48 additions & 0 deletions
48
src/test/java/io/fabric8/maven/docker/config/RegistryAuthConfigurationTest.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,48 @@ | ||
package io.fabric8.maven.docker.config; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Map; | ||
|
||
import org.junit.Test; | ||
import static org.junit.Assert.*; | ||
|
||
public class RegistryAuthConfigurationTest { | ||
|
||
@Test | ||
public void deprecatedAuthTokenTest() throws ReflectiveOperationException { | ||
RegistryAuthConfiguration config = new RegistryAuthConfiguration(); | ||
setField(config, "authToken", "foo"); | ||
Map map = config.toMap(); | ||
assertNull(map.get("authToken")); | ||
assertEquals("foo", map.get("auth")); | ||
} | ||
|
||
@Test | ||
public void invalidAuthTokenConfigTest() throws ReflectiveOperationException { | ||
RegistryAuthConfiguration config = new RegistryAuthConfiguration(); | ||
setField(config, "authToken", "foo"); | ||
setField(config, "auth", "bar"); | ||
try { | ||
config.toMap(); | ||
fail("Should throw an exception because both 'auth' and 'authToken' is specified"); | ||
} catch (IllegalStateException exp) { | ||
|
||
} | ||
} | ||
|
||
@Test | ||
public void authTest() throws ReflectiveOperationException { | ||
RegistryAuthConfiguration config = new RegistryAuthConfiguration(); | ||
setField(config, "auth", "bar"); | ||
Map map = config.toMap(); | ||
assertNull(map.get("authToken")); | ||
assertEquals("bar", map.get("auth")); | ||
} | ||
|
||
|
||
private void setField(Object obj, String name, Object value) throws ReflectiveOperationException { | ||
Field field = obj.getClass().getDeclaredField(name); | ||
field.setAccessible(true); | ||
field.set(obj, value); | ||
} | ||
} |
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