Esempio n. 1
0
        public async Task AppRoleLoginConnector_Test()
        {
            // PRE-Test

            VaultSystemBackend vaultSystemBackend = new VaultSystemBackend(_vault.TokenID, _vault);
            string             approleMountName   = _UK.GetKey("AppAuth");

            // Create an AppRole authentication connection.
            AppRoleAuthEngine appRoleAuthEngine = (AppRoleAuthEngine)_vault.ConnectAuthenticationBackend(EnumBackendTypes.A_AppRole, "AppRole", approleMountName);


            // Create an Authentication method of App Role.	- This only needs to be done when the Auth method is created.
            AuthMethod am = new AuthMethod(approleMountName, EnumAuthMethods.AppRole);
            bool       rc = await vaultSystemBackend.AuthEnable(am);

            string  rName = _UK.GetKey("Role");
            AppRole roleA = new AppRole(rName);

            Assert.True(await appRoleAuthEngine.SaveRole(roleA));

            string roleID = await appRoleAuthEngine.ReadRoleID(roleA.Name);

            // Now create the a secret
            AppRoleSecret secret_A = await appRoleAuthEngine.GenerateSecretID(roleA.Name);


            // ACTUAL TEST
            // Create Login Connector
            AppRoleLoginConnector loginConnector = new AppRoleLoginConnector(_vault, approleMountName, "Test AppRole", roleID, secret_A.ID);
            bool result = await loginConnector.Connect(true);

            Assert.IsTrue(result, "A10:  Login Failed");
        }
Esempio n. 2
0
        /// <summary>
        /// This particular test was running consistently 15x slower than any other test.  ~250ms
        /// </summary>
        /// <returns></returns>
        public async Task AppRoleBE_UpdateRoleID()
        {
            string  rName = _uniqueKeys.GetKey("Role");
            AppRole ar    = new AppRole(rName);
            bool    rc    = await _appRoleAuthEngine.SaveRole(ar);

            // Now read a Role ID for it.
            string roleID = await _appRoleAuthEngine.ReadRoleID(ar.Name);

            // Update the role ID
            rc = await _appRoleAuthEngine.UpdateAppRoleID(ar.Name, "newDomain");

            string roleIDNew = await _appRoleAuthEngine.ReadRoleID(ar.Name);

            Assert.AreEqual("newDomain", roleIDNew);
            Console.WriteLine("AppRoleBE_UpdateRoleID Finished OK!");
        }
Esempio n. 3
0
        public async Task ReadValidRoleID_Returns_RoleID()
        {
            string rName = _uniqueKeys.GetKey("Role");

            AppRole ar = new AppRole(rName);

            Assert.True(await _appRoleAuthEngine.SaveRole(ar));

            string Id = await _appRoleAuthEngine.ReadRoleID(rName);

            Assert.NotNull(Id);
        }