public void UserLookup_WhenTargetUserDoesNotExist_ShouldReturnNull()
        {
            SyncTestHelpers.RunRosTestAsync(async() =>
            {
                var admin = await User.LoginAsync(SyncTestHelpers.AdminCredentials(), SyncTestHelpers.AuthServerUri);

                var lookupResponse = await admin.RetrieveInfoForUserAsync(Credentials.Provider.UsernamePassword, "something");
                Assert.That(lookupResponse, Is.Null);
            });
        }
        public void UserLookup_WhenTargetUserIsSelf_ShouldReturnResponse()
        {
            SyncTestHelpers.RunRosTestAsync(async() =>
            {
                var admin = await User.LoginAsync(SyncTestHelpers.AdminCredentials(), SyncTestHelpers.AuthServerUri);

                var lookupResponse = await admin.RetrieveInfoForUserAsync(Credentials.Provider.UsernamePassword, Constants.AdminUsername);

                Assert.That(lookupResponse.Identity, Is.EqualTo(admin.Identity));
                Assert.That(lookupResponse.IsAdmin, Is.True);
                Assert.That(lookupResponse.Accounts, Is.Not.Empty);
                var passwordAccount = lookupResponse.Accounts.SingleOrDefault(a => a.Provider == Credentials.Provider.UsernamePassword);

                Assert.That(passwordAccount, Is.Not.Null);
                Assert.That(passwordAccount.ProviderUserIdentity, Is.EqualTo(Constants.AdminUsername));
            });
        }
        public void AdminChangePasswordTest()
        {
            SyncTestHelpers.RunRosTestAsync(async() =>
            {
                var userId      = Guid.NewGuid().ToString();
                var credentials = Credentials.UsernamePassword(userId, OriginalPassword, createUser: true);
                var user        = await User.LoginAsync(credentials, SyncTestHelpers.AuthServerUri);
                var identity    = user.Identity;
                await user.LogOutAsync();

                var admin = await User.LoginAsync(SyncTestHelpers.AdminCredentials(), SyncTestHelpers.AuthServerUri);
                await admin.ChangePasswordAsync(identity, NewPassword);

                await admin.LogOutAsync();

                Assert.That(async() => await admin.ChangePasswordAsync(identity, "c"), Throws.TypeOf <InvalidOperationException>());

                await TestNewPassword(userId);
            });
        }
        public void UserLookup_WhenTargetUserExists_ShouldReturnResponse()
        {
            SyncTestHelpers.RunRosTestAsync(async() =>
            {
                var admin = await User.LoginAsync(SyncTestHelpers.AdminCredentials(), SyncTestHelpers.AuthServerUri);

                var aliceUsername = Guid.NewGuid().ToString();
                var alice         = await User.LoginAsync(Credentials.UsernamePassword(aliceUsername, "a", createUser: true), SyncTestHelpers.AuthServerUri);

                var lookupResponse = await admin.RetrieveInfoForUserAsync(Credentials.Provider.UsernamePassword, aliceUsername);

                Assert.That(lookupResponse.Identity, Is.EqualTo(alice.Identity));
                Assert.That(lookupResponse.IsAdmin, Is.False);

                Assert.That(lookupResponse.Accounts, Is.Not.Empty);
                var passwordAccount = lookupResponse.Accounts.SingleOrDefault(a => a.Provider == Credentials.Provider.UsernamePassword);

                Assert.That(passwordAccount, Is.Not.Null);
                Assert.That(passwordAccount.ProviderUserIdentity, Is.EqualTo(aliceUsername));
            });
        }