forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthConfigTest.java
More file actions
64 lines (48 loc) · 2.21 KB
/
Copy pathAuthConfigTest.java
File metadata and controls
64 lines (48 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.github.dockerjava.api.model;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.dockerjava.core.RemoteApiVersion;
import org.testng.annotations.Test;
import java.io.IOException;
import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.notNullValue;
import static org.testng.Assert.assertEquals;
public class AuthConfigTest {
@Test
public void defaultServerAddress() throws Exception {
assertEquals(new AuthConfig().getRegistryAddress(), "https://index.docker.io/v1/");
}
@Test
public void serderDocs1() throws IOException {
final ObjectMapper mapper = new ObjectMapper();
final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(AuthConfig.class);
final AuthConfig authConfig = testRoundTrip(RemoteApiVersion.VERSION_1_22,
"/other/AuthConfig/docs1.json",
type
);
assertThat(authConfig, notNullValue());
assertThat(authConfig.getUsername(), is("jdoe"));
assertThat(authConfig.getPassword(), is("secret"));
assertThat(authConfig.getEmail(), is("jdoe@acme.com"));
final AuthConfig authConfig1 = new AuthConfig().withUsername("jdoe")
.withPassword("secret")
.withEmail("jdoe@acme.com");
assertThat(authConfig1, equalTo(authConfig));
}
@Test
public void serderDocs2() throws IOException {
final ObjectMapper mapper = new ObjectMapper();
final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(AuthConfig.class);
final AuthConfig authConfig = testRoundTrip(RemoteApiVersion.VERSION_1_22,
"/other/AuthConfig/docs2.json",
type
);
assertThat(authConfig, notNullValue());
assertThat(authConfig.getRegistrytoken(), is("9cbaf023786cd7..."));
final AuthConfig authConfig1 = new AuthConfig().withRegistrytoken("9cbaf023786cd7...");
assertThat(authConfig1, equalTo(authConfig));
}
}