Exemplo n.º 1
0
        public void TestGetUser()
        {
            IIdentityProvider provider = Bootstrapper.CreateIdentityProvider();
            User userByName            = provider.GetUserByName(Bootstrapper.Settings.TestIdentity.Username);

            Assert.IsNotNull(userByName);
            Assert.AreEqual(Bootstrapper.Settings.TestIdentity.Username, userByName.Username);
            Assert.IsNotNull(userByName.Id);

            User user = provider.GetUser(userByName.Id);

            Assert.IsNotNull(user);
            Assert.AreEqual(Bootstrapper.Settings.TestIdentity.Username, user.Username);
            Assert.AreEqual(userByName.Id, user.Id);

            Console.WriteLine("User \"{0}\" (id: {1})", user.Username, user.Id);
            if (!user.Enabled)
            {
                Console.WriteLine("    Disabled");
            }
            if (!string.IsNullOrEmpty(user.Email))
            {
                Console.WriteLine("    Email: {0}", user.Email);
            }
            if (!string.IsNullOrEmpty(user.DefaultRegion))
            {
                Console.WriteLine("    Default region: {0}", user.DefaultRegion);
            }
            if (user.DomainId != null)
            {
                Console.WriteLine("    Domain ID: {0}", user.DomainId);
            }
        }
Exemplo n.º 2
0
        public void TestListUserCredentials()
        {
            IIdentityProvider provider = Bootstrapper.CreateIdentityProvider();
            User user = provider.GetUserByName(Bootstrapper.Settings.TestIdentity.Username);
            IEnumerable <UserCredential> credentials = provider.ListUserCredentials(user.Id);

            Assert.IsNotNull(credentials);
            Assert.IsTrue(credentials.Any());

            foreach (IGrouping <string, UserCredential> grouping in credentials.GroupBy(i => i.Name))
            {
                Console.WriteLine(grouping.Key);
                foreach (UserCredential credential in grouping)
                {
                    Console.WriteLine("    {0}: {1}", credential.Username, credential.APIKey);
                }
            }
        }
Exemplo n.º 3
0
        public void TestGetUserCredential()
        {
            IIdentityProvider provider = Bootstrapper.CreateIdentityProvider();
            User user = provider.GetUserByName(Bootstrapper.Settings.TestIdentity.Username);
            IEnumerable <UserCredential> credentials = provider.ListUserCredentials(user.Id);

            Assert.IsNotNull(credentials);
            Assert.IsTrue(credentials.Any());

            foreach (UserCredential credential in credentials)
            {
                UserCredential value = provider.GetUserCredential(user.Id, credential.Name);
                Assert.AreEqual(credential.Username, value.Username);
                Assert.AreEqual(credential.Name, value.Name);
                Assert.AreEqual(credential.APIKey, value.APIKey);
            }

            Console.WriteLine(JsonConvert.SerializeObject(credentials, Formatting.Indented));
        }