public async Task RetrieveCurrentToken_Success() { Token tokenInfo = await _tokenAuthEngine.GetCurrentTokenInfo(); Assert.IsNotNull(tokenInfo); Assert.AreEqual(VaultServerRef.rootToken, tokenInfo.ID); }
/// <summary> /// Establishes a connection with the specified token. /// </summary> /// <returns></returns> protected override async Task <bool> InternalConnection() { try { // We must replace the Vault Token if the value is currently empty, We need something to connect to Vault with. if (_vaultAgent.TokenID == string.Empty) { _vaultAgent.TokenID = TokenId; //_vaultAgent._vaultAccessTokenID = TokenId; } // In reality, we are not connecting anything. Tokens are a unique case, in which you either know the token value or you do not. // If you know it, then we just validate it is a token and copy its information to the Response object. Token token = await _tokenAuthEngine.GetCurrentTokenInfo(); Response = new LoginResponse(); if (token == null) { return(false); } // We need to move some of the values from the Token to the response object Response.ClientToken = token.ID; Response.Policies = token.Policies; Response.IdentityPolicies = token.IdentityPolicies; Response.Accessor = token.AccessorTokenID; Response.Renewable = token.IsRenewable; Response.EntityId = token.EntityId; Response.Metadata = token.Metadata; // TODO - Adjust //Response.TokenType = token.TokenType; return(true); } // Forbidden means token does not have permission catch (System.AggregateException e) { foreach (Exception ex in e.InnerExceptions) { if (ex is VaultForbiddenException) { return(false); } } throw; } catch (Exception e) { throw; } }