public void AuthMethod_ConstructViaEnum_Success(EnumAuthMethods i, string val) { string sPath = "GHI" + i.ToString(); AuthMethod am = new AuthMethod(sPath, i); Assert.AreEqual(am.TypeAsString, val); }
// Test that we can enable an authentication method with the provided name and no config options. We test all possible authentication methods. //public async Task SystemBE_Auth_Enable_NoConfigOptions_Works([Range((int)EnumAuthMethods.AppRole, (int)EnumAuthMethods.Token)] EnumAuthMethods auth) { public async Task Auth_Enable_NoConfigOptions_Works(EnumAuthMethods auth) { string a = Guid.NewGuid().ToString(); string c = a.Substring(0, 5); string sPath = c + (int)auth; Debug.WriteLine("NBoConfig: Path = " + sPath); AuthMethod am = new AuthMethod(sPath, auth); Assert.True(await _vaultSystemBackend.AuthEnable(am)); }
public AuthMethod(string path, string type) { // We do not call the actual property setters here, because of an endless loop situation. _type = type; _typeEnum = AuthMethodEnumConverters.EnumAuthMethodsFromString(type); Config = new AuthConfig(); // We also accept a null path value. We have to allow this because Vault does not return the path as part of the JSON object, but // rather as a dictionary key element. We are assuming that if the value is null then the caller will eventually get around to // setting the path or name.... if (path != null) { SetPathAndName(path); } }
/// <summary> /// Constructor that accepts our EnumAuthMethod argument for constructing the method. /// </summary> /// <param name="path">The path to the mount point for the provided Authentication Method</param> /// <param name="authenticationMethod">EnumAuthMethod - Type of authentication method object to create</param> public AuthMethod(string path, EnumAuthMethods authenticationMethod) { _typeEnum = authenticationMethod; _type = AuthMethodEnumConverters.EnumAuthMethodsToString(_typeEnum); Config = new AuthConfig(); if (path == null) { throw new ArgumentException("The path value cannot be null."); } if (path == "") { throw new ArgumentException("The path value cannot be an empty string."); } SetPathAndName(path); }
/// <summary> /// This function takes the EnumAuthMethods value and converts it to the Vault proper string name. /// </summary> /// <param name="method">The EnumAuthMethods value that corresponds to a proper Vault Authentication Method string name.</param> /// <returns>String value of the method.</returns> public static string EnumAuthMethodsToString(EnumAuthMethods method) { // Never change these values unless the Vault backend changes them. Serialization / Deserialization will cease // to function if they do not match. switch (method) { case EnumAuthMethods.AppRole: return("approle"); case EnumAuthMethods.Token: return("token"); case EnumAuthMethods.AWS: return("aws"); case EnumAuthMethods.GoogleCloud: return("gcp"); case EnumAuthMethods.Kubernetes: return("kubernetes"); case EnumAuthMethods.GitHub: return("github"); case EnumAuthMethods.LDAP: return("ldap"); case EnumAuthMethods.Okta: return("okta"); // case EnumAuthMethods.Radius: // return "radius"; case EnumAuthMethods.TLSCertificates: return("cert"); case EnumAuthMethods.UsernamePassword: return("userpass"); // Vault .1 case EnumAuthMethods.Azure: // Vault .1 sAuthType = "azure"; break; // case EnumAuthMethods.Tokens: // sAuthType = "auth"; break; default: string msg = "The EnumAuthMethod value of " + method + "is invalid."; throw new ArgumentException(msg); } }
public void AuthMethod_ConstructViaString(EnumAuthMethods i, string val) { AuthMethod am = new AuthMethod(_uniqueKeys.GetKey("TST"), val); Assert.AreEqual(i, am.Type); }