Exemplo n.º 1
0
        public void TestIdentities()
        {
            CreateIdentityPool(out poolId, out poolName);

            DateTime identityCreationTime = DateTime.UtcNow;
            var      identityId           = CreateIdentity(poolId, poolName);

            var identity = Client.DescribeIdentity(identityId);

            Assert.AreEqual(identityId, identity.IdentityId);
            Assert.IsTrue((identity.CreationDate - identityCreationTime).GetAbsolute() < TimeSpan.FromMinutes(1));
            Assert.AreEqual(0, identity.Logins.Count);

            Credentials credentials = UtilityMethods.WaitUntilSuccess <Credentials>(() => Client.GetCredentialsForIdentity(identityId).Credentials);

            Assert.IsNotNull(credentials);
            CognitoSync.TestCredentials(credentials);

            var getOpenIdResult = Client.GetOpenIdToken(new GetOpenIdTokenRequest
            {
                IdentityId = identityId,
            });

            Assert.IsFalse(string.IsNullOrEmpty(getOpenIdResult.IdentityId));
            Assert.IsFalse(string.IsNullOrEmpty(getOpenIdResult.Token));

            var identities = GetAllIdentities(poolId);

            Assert.IsNotNull(identities);
            Assert.AreEqual(1, identities.Count);

            identities = GetAllIdentities(poolId);
            Assert.IsNotNull(identities);
            Assert.AreEqual(1, identities.Count);

            var roles = Client.GetIdentityPoolRoles(new GetIdentityPoolRolesRequest
            {
                IdentityPoolId = poolId
            }).Roles;

            Assert.AreEqual(NumberOfPoolRoles, roles.Count);
        }