model: add missing fields to AuthMethod
model
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f3cc16f44a
commit
b0d2b038eb
10
.drone.yml
10
.drone.yml
@ -25,12 +25,12 @@ steps:
|
|||||||
- name: unit-integration-tests
|
- name: unit-integration-tests
|
||||||
image: maven:3-jdk-11
|
image: maven:3-jdk-11
|
||||||
environment:
|
environment:
|
||||||
VAULT_VERSION: 1.10.0
|
VAULT_VERSION: 1.10.1
|
||||||
commands:
|
commands:
|
||||||
- curl -s -o vault_1.10.0_linux_amd64.zip https://releases.hashicorp.com/vault/1.10.0/vault_1.10.0_linux_amd64.zip
|
- curl -s -o vault_1.10.1_linux_amd64.zip https://releases.hashicorp.com/vault/1.10.1/vault_1.10.1_linux_amd64.zip
|
||||||
- curl -s https://releases.hashicorp.com/vault/1.10.0/vault_1.10.0_SHA256SUMS | grep linux_amd64 | sha256sum -c
|
- curl -s https://releases.hashicorp.com/vault/1.10.1/vault_1.10.1_SHA256SUMS | grep linux_amd64 | sha256sum -c
|
||||||
- unzip vault_1.10.0_linux_amd64.zip
|
- unzip vault_1.10.1_linux_amd64.zip
|
||||||
- rm vault_1.10.0_linux_amd64.zip
|
- rm vault_1.10.1_linux_amd64.zip
|
||||||
- mv vault /bin/
|
- mv vault /bin/
|
||||||
- mvn -B -P integration-test verify
|
- mvn -B -P integration-test verify
|
||||||
when:
|
when:
|
||||||
|
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -6,10 +6,10 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
jdk: [ 11, 17 ]
|
jdk: [ 11, 17 ]
|
||||||
vault: [ '1.10.0' ]
|
vault: [ '1.10.1' ]
|
||||||
include:
|
include:
|
||||||
- jdk: 11
|
- jdk: 11
|
||||||
vault: '1.10.0'
|
vault: '1.10.1'
|
||||||
analysis: true
|
analysis: true
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
@ -7,11 +7,12 @@
|
|||||||
* Add `migration`, `recovery_seal` and `storage_type` fields to `SealReponse` model
|
* Add `migration`, `recovery_seal` and `storage_type` fields to `SealReponse` model
|
||||||
* Add support for `wrap_info` in data response models
|
* Add support for `wrap_info` in data response models
|
||||||
* Dependency updates
|
* Dependency updates
|
||||||
* model and response classes implement `Serializable` (#57)
|
* Model and response classes implement `Serializable` (#57)
|
||||||
* split `SercretResponse` into `PlainSecretResponse` and `MetaSecretResponse` subclasses (common API unchanged)
|
* Split `SercretResponse` into `PlainSecretResponse` and `MetaSecretResponse` subclasses (common API unchanged)
|
||||||
|
* Add missing fields to `AuthMethod` model
|
||||||
|
|
||||||
### Test
|
### Test
|
||||||
* Tested against Vault 1.10.0
|
* Tested against Vault 1.10.1
|
||||||
|
|
||||||
|
|
||||||
## 1.0.1 (2021-11-21)
|
## 1.0.1 (2021-11-21)
|
||||||
|
@ -34,20 +34,32 @@ import java.util.Objects;
|
|||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public final class AuthMethod implements Serializable {
|
public final class AuthMethod implements Serializable {
|
||||||
private static final long serialVersionUID = -5241997986380823391L;
|
private static final long serialVersionUID = -2718660627880077335L;
|
||||||
|
|
||||||
private AuthBackend type;
|
private AuthBackend type;
|
||||||
private String rawType;
|
private String rawType;
|
||||||
|
|
||||||
|
@JsonProperty("accessor")
|
||||||
|
private String accessor;
|
||||||
|
|
||||||
@JsonProperty("description")
|
@JsonProperty("description")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@JsonProperty("config")
|
@JsonProperty("config")
|
||||||
private Map<String, String> config;
|
private Map<String, String> config;
|
||||||
|
|
||||||
|
@JsonProperty("external_entropy_access")
|
||||||
|
private boolean externalEntropyAccess;
|
||||||
|
|
||||||
@JsonProperty("local")
|
@JsonProperty("local")
|
||||||
private boolean local;
|
private boolean local;
|
||||||
|
|
||||||
|
@JsonProperty("seal_wrap")
|
||||||
|
private boolean sealWrap;
|
||||||
|
|
||||||
|
@JsonProperty("uuid")
|
||||||
|
private String uuid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param type Backend type, passed to {@link AuthBackend#forType(String)}
|
* @param type Backend type, passed to {@link AuthBackend#forType(String)}
|
||||||
*/
|
*/
|
||||||
@ -71,6 +83,14 @@ public final class AuthMethod implements Serializable {
|
|||||||
return rawType;
|
return rawType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Accessor
|
||||||
|
* @since 1.1
|
||||||
|
*/
|
||||||
|
public String getAccessor() {
|
||||||
|
return accessor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Description
|
* @return Description
|
||||||
*/
|
*/
|
||||||
@ -85,6 +105,14 @@ public final class AuthMethod implements Serializable {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Backend has access to external entropy source
|
||||||
|
* @since 1.1
|
||||||
|
*/
|
||||||
|
public boolean isExternalEntropyAccess() {
|
||||||
|
return externalEntropyAccess;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Is local backend
|
* @return Is local backend
|
||||||
*/
|
*/
|
||||||
@ -92,6 +120,22 @@ public final class AuthMethod implements Serializable {
|
|||||||
return local;
|
return local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Seal wrapping enabled
|
||||||
|
* @since 1.1
|
||||||
|
*/
|
||||||
|
public boolean isSealWrap() {
|
||||||
|
return sealWrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Backend UUID
|
||||||
|
* @since 1.1
|
||||||
|
*/
|
||||||
|
public String getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
@ -102,13 +146,17 @@ public final class AuthMethod implements Serializable {
|
|||||||
AuthMethod that = (AuthMethod) o;
|
AuthMethod that = (AuthMethod) o;
|
||||||
return local == that.local &&
|
return local == that.local &&
|
||||||
type == that.type &&
|
type == that.type &&
|
||||||
|
externalEntropyAccess == that.externalEntropyAccess &&
|
||||||
|
sealWrap == that.sealWrap &&
|
||||||
Objects.equals(rawType, that.rawType) &&
|
Objects.equals(rawType, that.rawType) &&
|
||||||
|
Objects.equals(accessor, that.accessor) &&
|
||||||
Objects.equals(description, that.description) &&
|
Objects.equals(description, that.description) &&
|
||||||
Objects.equals(config, that.config);
|
Objects.equals(config, that.config) &&
|
||||||
|
Objects.equals(uuid, that.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(type, rawType, description, config, local);
|
return Objects.hash(type, rawType, accessor, description, config, externalEntropyAccess, local, sealWrap, uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
|||||||
* @since 0.1
|
* @since 0.1
|
||||||
*/
|
*/
|
||||||
class HTTPVaultConnectorIT {
|
class HTTPVaultConnectorIT {
|
||||||
private static String VAULT_VERSION = "1.10.0"; // The vault version this test is supposed to run against.
|
private static String VAULT_VERSION = "1.10.1"; // The vault version this test is supposed to run against.
|
||||||
private static final String KEY1 = "E38bkCm0VhUvpdCKGQpcohhD9XmcHJ/2hreOSY019Lho";
|
private static final String KEY1 = "E38bkCm0VhUvpdCKGQpcohhD9XmcHJ/2hreOSY019Lho";
|
||||||
private static final String KEY2 = "O5OHwDleY3IiPdgw61cgHlhsrEm6tVJkrxhF6QAnILd1";
|
private static final String KEY2 = "O5OHwDleY3IiPdgw61cgHlhsrEm6tVJkrxhF6QAnILd1";
|
||||||
private static final String KEY3 = "mw7Bm3nbt/UWa/juDjjL2EPQ04kiJ0saC5JEXwJvXYsB";
|
private static final String KEY3 = "mw7Bm3nbt/UWa/juDjjL2EPQ04kiJ0saC5JEXwJvXYsB";
|
||||||
|
@ -38,9 +38,13 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
class AuthMethodsResponseTest extends AbstractModelTest<AuthMethodsResponse> {
|
class AuthMethodsResponseTest extends AbstractModelTest<AuthMethodsResponse> {
|
||||||
private static final String GH_PATH = "github/";
|
private static final String GH_PATH = "github/";
|
||||||
private static final String GH_TYPE = "github";
|
private static final String GH_TYPE = "github";
|
||||||
|
private static final String GH_UUID = "4b42d1a4-0a0d-3c88-ae90-997e0c8b41be";
|
||||||
|
private static final String GH_ACCESSOR = "auth_github_badd7fd0";
|
||||||
private static final String GH_DESCR = "GitHub auth";
|
private static final String GH_DESCR = "GitHub auth";
|
||||||
private static final String TK_PATH = "token/";
|
private static final String TK_PATH = "token/";
|
||||||
private static final String TK_TYPE = "token";
|
private static final String TK_TYPE = "token";
|
||||||
|
private static final String TK_UUID = "32ea9681-6bd6-6cec-eec3-d11260ba9741";
|
||||||
|
private static final String TK_ACCESSOR = "auth_token_ac0dd95a";
|
||||||
private static final String TK_DESCR = "token based credentials";
|
private static final String TK_DESCR = "token based credentials";
|
||||||
private static final Integer TK_LEASE_TTL = 0;
|
private static final Integer TK_LEASE_TTL = 0;
|
||||||
private static final Integer TK_MAX_LEASE_TTL = 0;
|
private static final Integer TK_MAX_LEASE_TTL = 0;
|
||||||
@ -48,8 +52,13 @@ class AuthMethodsResponseTest extends AbstractModelTest<AuthMethodsResponse> {
|
|||||||
private static final String RES_JSON = "{\n" +
|
private static final String RES_JSON = "{\n" +
|
||||||
" \"data\": {" +
|
" \"data\": {" +
|
||||||
" \"" + GH_PATH + "\": {\n" +
|
" \"" + GH_PATH + "\": {\n" +
|
||||||
|
" \"uuid\": \"" + GH_UUID + "\",\n" +
|
||||||
" \"type\": \"" + GH_TYPE + "\",\n" +
|
" \"type\": \"" + GH_TYPE + "\",\n" +
|
||||||
" \"description\": \"" + GH_DESCR + "\"\n" +
|
" \"accessor\": \"" + GH_ACCESSOR + "\",\n" +
|
||||||
|
" \"description\": \"" + GH_DESCR + "\",\n" +
|
||||||
|
" \"external_entropy_access\": false,\n" +
|
||||||
|
" \"local\": false,\n" +
|
||||||
|
" \"seal_wrap\": false\n" +
|
||||||
" },\n" +
|
" },\n" +
|
||||||
" \"" + TK_PATH + "\": {\n" +
|
" \"" + TK_PATH + "\": {\n" +
|
||||||
" \"config\": {\n" +
|
" \"config\": {\n" +
|
||||||
@ -57,7 +66,12 @@ class AuthMethodsResponseTest extends AbstractModelTest<AuthMethodsResponse> {
|
|||||||
" \"max_lease_ttl\": " + TK_MAX_LEASE_TTL + "\n" +
|
" \"max_lease_ttl\": " + TK_MAX_LEASE_TTL + "\n" +
|
||||||
" },\n" +
|
" },\n" +
|
||||||
" \"description\": \"" + TK_DESCR + "\",\n" +
|
" \"description\": \"" + TK_DESCR + "\",\n" +
|
||||||
" \"type\": \"" + TK_TYPE + "\"\n" +
|
" \"type\": \"" + TK_TYPE + "\",\n" +
|
||||||
|
" \"uuid\": \"" + TK_UUID + "\",\n" +
|
||||||
|
" \"accessor\": \"" + TK_ACCESSOR + "\",\n" +
|
||||||
|
" \"external_entropy_access\": false,\n" +
|
||||||
|
" \"local\": true,\n" +
|
||||||
|
" \"seal_wrap\": false\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
"}";
|
"}";
|
||||||
@ -108,15 +122,31 @@ class AuthMethodsResponseTest extends AbstractModelTest<AuthMethodsResponse> {
|
|||||||
assertEquals(AuthBackend.GITHUB, method.getType(), "Incorrect parsed type for GitHub");
|
assertEquals(AuthBackend.GITHUB, method.getType(), "Incorrect parsed type for GitHub");
|
||||||
assertEquals(GH_DESCR, method.getDescription(), "Incorrect description for GitHub");
|
assertEquals(GH_DESCR, method.getDescription(), "Incorrect description for GitHub");
|
||||||
assertNull(method.getConfig(), "Unexpected config for GitHub");
|
assertNull(method.getConfig(), "Unexpected config for GitHub");
|
||||||
|
assertEquals(GH_UUID, method.getUuid(), "Unexpected UUID for GitHub");
|
||||||
|
assertEquals(GH_ACCESSOR, method.getAccessor(), "Unexpected accessor for GitHub");
|
||||||
|
assertFalse(method.isLocal(), "Unexpected local flag for GitHub");
|
||||||
|
assertFalse(method.isExternalEntropyAccess(), "Unexpected external entropy flag for GitHub");
|
||||||
|
assertFalse(method.isSealWrap(), "Unexpected seal wrap flag for GitHub");
|
||||||
|
|
||||||
// Verify first method.
|
// Verify second method.
|
||||||
method = supported.get(TK_PATH);
|
method = supported.get(TK_PATH);
|
||||||
assertEquals(TK_TYPE, method.getRawType(), "Incorrect raw type for Token");
|
assertEquals(TK_TYPE, method.getRawType(), "Incorrect raw type for Token");
|
||||||
assertEquals(AuthBackend.TOKEN, method.getType(), "Incorrect parsed type for Token");
|
assertEquals(AuthBackend.TOKEN, method.getType(), "Incorrect parsed type for Token");
|
||||||
assertEquals(TK_DESCR, method.getDescription(), "Incorrect description for Token");
|
assertEquals(TK_DESCR, method.getDescription(), "Incorrect description for Token");
|
||||||
|
assertEquals(TK_UUID, method.getUuid(), "Unexpected UUID for Token");
|
||||||
|
assertEquals(TK_ACCESSOR, method.getAccessor(), "Unexpected accessor for Token");
|
||||||
|
assertTrue(method.isLocal(), "Unexpected local flag for Token");
|
||||||
|
assertFalse(method.isExternalEntropyAccess(), "Unexpected external entropy flag for Token");
|
||||||
|
assertFalse(method.isSealWrap(), "Unexpected seal wrap flag for GitHub");
|
||||||
|
|
||||||
assertNotNull(method.getConfig(), "Missing config for Token");
|
assertNotNull(method.getConfig(), "Missing config for Token");
|
||||||
assertEquals(2, method.getConfig().size(), "Unexpected config size for Token");
|
assertEquals(
|
||||||
assertEquals(TK_LEASE_TTL.toString(), method.getConfig().get("default_lease_ttl"), "Incorrect lease TTL config");
|
Map.of(
|
||||||
assertEquals(TK_MAX_LEASE_TTL.toString(), method.getConfig().get("max_lease_ttl"), "Incorrect max lease TTL config");
|
"default_lease_ttl", TK_LEASE_TTL.toString(),
|
||||||
|
"max_lease_ttl", TK_MAX_LEASE_TTL.toString()
|
||||||
|
),
|
||||||
|
method.getConfig(),
|
||||||
|
"Unexpected config for Token"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user