Home / Class/ CredentialTests Class — spring-boot Architecture

CredentialTests Class — spring-boot Architecture

Architecture documentation for the CredentialTests class in CredentialTests.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

buildpack/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/configuration/CredentialTests.java lines 35–90

class CredentialTests {

	@Test
	@WithResource(name = "credentials.json", content = """
			{
			  "ServerURL": "https://index.docker.io/v1/",
			  "Username": "user",
			  "Secret": "secret"
			}
			""")
	void createWhenUserCredentials() throws Exception {
		Credential credentials = getCredentials("credentials.json");
		assertThat(credentials.getUsername()).isEqualTo("user");
		assertThat(credentials.getSecret()).isEqualTo("secret");
		assertThat(credentials.getServerUrl()).isEqualTo("https://index.docker.io/v1/");
		assertThat(credentials.isIdentityToken()).isFalse();
	}

	@Test
	@WithResource(name = "credentials.json", content = """
			{
			  "ServerURL": "https://index.docker.io/v1/",
			  "Username": "<token>",
			  "Secret": "secret"
			}
			""")
	void createWhenTokenCredentials() throws Exception {
		Credential credentials = getCredentials("credentials.json");
		assertThat(credentials.getUsername()).isEqualTo("<token>");
		assertThat(credentials.getSecret()).isEqualTo("secret");
		assertThat(credentials.getServerUrl()).isEqualTo("https://index.docker.io/v1/");
		assertThat(credentials.isIdentityToken()).isTrue();
	}

	@Test
	@WithResource(name = "credentials.json", content = """
			{
			  "Username": "user",
			  "Secret": "secret"
			}
			""")
	void createWhenNoServerUrl() throws Exception {
		Credential credentials = getCredentials("credentials.json");
		assertThat(credentials.getUsername()).isEqualTo("user");
		assertThat(credentials.getSecret()).isEqualTo("secret");
		assertThat(credentials.getServerUrl()).isNull();
		assertThat(credentials.isIdentityToken()).isFalse();
	}

	private Credential getCredentials(String name) throws IOException {
		try (InputStream inputStream = new ClassPathResource(name).getInputStream()) {
			return new Credential(SharedJsonMapper.get().readTree(inputStream));
		}
	}

}

Domain

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free