Example #1
0
        public async Task ListSecretIDAccessors_Success()
        {
            string roleName_A = _uniqueKeys.GetKey("RoleAC");
            string roleName_B = _uniqueKeys.GetKey("RoleAC");

            AppRole roleA = new AppRole(roleName_A);
            AppRole roleB = new AppRole(roleName_B);

            Assert.True(await _appRoleAuthEngine.SaveRole(roleA));
            Assert.True(await _appRoleAuthEngine.SaveRole(roleB));


            // Now create the 4 secrets
            AppRoleSecret secret_A1 = await _appRoleAuthEngine.GenerateSecretID(roleA.Name);

            AppRoleSecret secret_A2 = await _appRoleAuthEngine.GenerateSecretID(roleA.Name);

            AppRoleSecret secret_A3 = await _appRoleAuthEngine.GenerateSecretID(roleA.Name);

            AppRoleSecret secret_B1 = await _appRoleAuthEngine.GenerateSecretID(roleB.Name);


            // Acquire the list of secrets.
            List <string> secrets_A = await _appRoleAuthEngine.ListSecretIDAccessors(roleA.Name);

            List <string> secrets_B = await _appRoleAuthEngine.ListSecretIDAccessors(roleB.Name);

            // Make sure the counts and the correct secrets are in each list.
            Assert.AreEqual(3, secrets_A.Count);
            Assert.AreEqual(1, secrets_B.Count);

            Assert.Contains(secret_A1.Accessor, secrets_A);
            Assert.Contains(secret_A2.Accessor, secrets_A);
            Assert.Contains(secret_A3.Accessor, secrets_A);

            Assert.Contains(secret_B1.Accessor, secrets_B);

            TestContext.WriteLine("Auth Engine Mount Point:  {0}  |  Mount Point Path:  {1}", _appRoleAuthEngine.MountPoint, _appRoleAuthEngine.MountPointPath);
            TestContext.WriteLine("Role A:     {0}", roleA.Name);
            TestContext.WriteLine("Role A:     {0}", roleB.Name);
            TestContext.WriteLine("Secret A1:  ID: {0}  |  Accessor: {1}", secret_A1.ID, secret_A1.Accessor);
            TestContext.WriteLine("Secret A2:  ID: {0}  |  Accessor: {1}", secret_A2.ID, secret_A2.Accessor);
            TestContext.WriteLine("Secret A3:  ID: {0}  |  Accessor: {1}", secret_A3.ID, secret_A3.Accessor);
            TestContext.WriteLine("Secret B1:  ID: {0}  |  Accessor: {1}", secret_B1.ID, secret_B1.Accessor);
        }