@Test public void login() { vaultUserPassAuth.auth = new VaultUserPassAuthAuth(); vaultUserPassAuth.auth.clientToken = "1"; vaultUserPassAuth.auth.renewable = true; vaultUserPassAuth.auth.leaseDurationSecs = 10; vaultLookupSelf.renewable = true; vaultLookupSelf.leaseDurationSecs = 10; vaultRenewSelf.auth = new VaultRenewSelfAuth(); vaultRenewSelf.auth.renewable = true; vaultRenewSelf.auth.leaseDurationSecs = 10; VaultToken token = vaultAuthManager.login(null); assertEquals("1", token.clientToken); token.created = EPOCH; token.nowSupplier = () -> EPOCH.plusSeconds(2); token = vaultAuthManager.login(token); vaultUserPassAuth.auth.clientToken = "2"; assertEquals("1", token.clientToken, "return from cache"); token.created = EPOCH; token.nowSupplier = () -> EPOCH.plusSeconds(8); vaultRenewSelf.auth.clientToken = "3"; token = vaultAuthManager.login(token); assertEquals("3", token.clientToken, "extended"); token.created = EPOCH; token.nowSupplier = () -> EPOCH.plusSeconds(2); lookupSelfShouldReturn403.set(true); vaultUserPassAuth.auth.clientToken = "4"; token = vaultAuthManager.login(token); assertEquals("4", token.clientToken, "invalid -> recreated"); lookupSelfShouldReturn403.set(false); token.created = EPOCH; token.nowSupplier = () -> EPOCH.plusSeconds(12); vaultUserPassAuth.auth.clientToken = "5"; token = vaultAuthManager.login(token); assertEquals("5", token.clientToken, "expired"); token.created = EPOCH; token.nowSupplier = () -> EPOCH.plusSeconds(8); token.leaseDurationSecs = 2; vaultUserPassAuth.auth.clientToken = "6"; token = vaultAuthManager.login(token); assertEquals("6", token.clientToken, "expires soon"); }
private VaultToken login() { VaultToken vaultToken = login(loginCache.get()); loginCache.set(vaultToken); return vaultToken; }
VaultAuthManager { private VaultToken login() { VaultToken vaultToken = login(loginCache.get()); loginCache.set(vaultToken); return vaultToken; } }
VaultAuthManager { private VaultToken login() { VaultToken vaultToken = login(loginCache.get()); loginCache.set(vaultToken); return vaultToken; } VaultAuthManager(VaultClient vaultClient, VaultRuntimeConfig serverConfig); }
VaultAuthManager { private VaultToken login() { VaultToken vaultToken = login(loginCache.get()); loginCache.set(vaultToken); return vaultToken; } VaultAuthManager(VaultClient vaultClient, VaultRuntimeConfig serverConfig); String getClientToken(); VaultToken login(VaultToken currentVaultToken); }
VaultAuthManager { private VaultToken login() { VaultToken vaultToken = login(loginCache.get()); loginCache.set(vaultToken); return vaultToken; } VaultAuthManager(VaultClient vaultClient, VaultRuntimeConfig serverConfig); String getClientToken(); VaultToken login(VaultToken currentVaultToken); static final String USERPASS_WRAPPING_TOKEN_PASSWORD_KEY; }