Skip to content

Commit fee921e

Browse files
committed
Fix #921, make AuthConfig compatible with indentitytoken
which was introduced in DOCKER API 1.23
1 parent 982396d commit fee921e

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

src/main/java/com/github/dockerjava/api/model/AuthConfig.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ public class AuthConfig implements Serializable {
4242
@JsonProperty("registrytoken")
4343
private String registrytoken;
4444

45+
/**
46+
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_23}
47+
*/
48+
@JsonProperty("identitytoken")
49+
private String identitytoken;
50+
4551
public String getUsername() {
4652
return username;
4753
}
@@ -87,6 +93,20 @@ public AuthConfig withAuth(String auth) {
8793
return this;
8894
}
8995

96+
/**
97+
* @see #identitytoken
98+
*/
99+
public String getIdentitytoken() {
100+
return identitytoken;
101+
}
102+
/**
103+
* @see #identitytoken
104+
*/
105+
public AuthConfig withIdentityToken(String identitytoken) {
106+
this.identitytoken = identitytoken;
107+
return this;
108+
}
109+
90110
/**
91111
* @see #registrytoken
92112
*/

src/test/java/com/github/dockerjava/api/model/AuthConfigTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,21 @@ public void serderDocs2() throws IOException {
6161

6262
assertThat(authConfig1, equalTo(authConfig));
6363
}
64+
65+
@Test
66+
public void compatibleWithIdentitytoken() throws IOException {
67+
final ObjectMapper mapper = new ObjectMapper();
68+
final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(AuthConfig.class);
69+
final AuthConfig authConfig = testRoundTrip(RemoteApiVersion.VERSION_1_23,
70+
"/other/AuthConfig/docs1.json",
71+
type
72+
);
73+
String auth = "YWRtaW46";
74+
String identitytoken = "1cba468e-8cbe-4c55-9098-2c2ed769e885";
75+
assertThat(authConfig, notNullValue());
76+
assertThat(authConfig.getAuth(), is(auth));
77+
assertThat(authConfig.getIdentitytoken(), is(identitytoken));
78+
final AuthConfig authConfig1 = new AuthConfig().withAuth(auth).withIdentityToken(identitytoken);
79+
assertThat(authConfig1, equalTo(authConfig));
80+
}
6481
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"auth": "YWRtaW46",
3+
"identitytoken": "1cba468e-8cbe-4c55-9098-2c2ed769e885"
4+
}

0 commit comments

Comments
 (0)