예제 #1
0
        public void CanLogInWithJwt()
        {
            var dataApiClient = new DataApiClient(ApiSetup.ApiConfiguration);

            Assume.That(dataApiClient.IsLoggedIn, Is.False);
            Assume.That(dataApiClient.LoggedInUsername, Is.Null);
            Assume.That(dataApiClient.IsAvailable());
            try
            {
                dataApiClient.Register("Test_sdfrgnbfgfdgj", "fgjerg", "sadfgfg", "egjdfbednbrgeo", "*****@*****.**");
            }
            catch (ApiException apiException)
            {
                if (apiException.StatusCode != HttpStatusCode.Conflict)
                {
                    throw;
                }
            }
            var authenticationResult = dataApiClient.Login("Test_sdfrgnbfgfdgj", "egjdfbednbrgeo");

            Assert.That(authenticationResult, Is.Not.Null);
            Assert.That(authenticationResult.IsAuthenticated, Is.True);
            Assert.That(dataApiClient.IsLoggedIn, Is.True);
            Assert.That(dataApiClient.LoggedInUsername, Is.EqualTo("test_sdfrgnbfgfdgj"));

            Assert.That(() => authenticationResult = dataApiClient.Login("invalidUser", "invalidPassword"), Throws.Nothing);
            Assert.That(authenticationResult.IsAuthenticated, Is.False);
        }
예제 #2
0
        public static AuthenticationResult RegisterAndLoginUserWithoutRoles(out IDataApiClient dataApiClient)
        {
            var username  = GenerateUsername();
            var password  = GeneratePassword();
            var email     = $"{username}@example.org";
            var firstName = "Jamie";
            var lastName  = "Doe";

            dataApiClient = new DataApiClient(ApiSetup.ApiConfiguration);
            dataApiClient.Register(username, firstName, lastName, password, email);
            return(dataApiClient.Login(username, password));
        }
예제 #3
0
        public void CanRegisterLoginAndDeleteUser()
        {
            Assume.That(adminDataApiClient.IsAvailable(), "API not available");
            var dataApiClient = new DataApiClient(ApiSetup.ApiConfiguration);

            var username  = UserGenerator.GenerateUsername();
            var password  = UserGenerator.GeneratePassword();
            var email     = $"{username}@example.org";
            var firstName = "Jamie";
            var lastName  = "Doe";

            Assert.That(() => dataApiClient.Register(username, firstName, lastName, password, email), Throws.Nothing);
            AuthenticationResult authenticationResult = null;

            Assert.That(() => authenticationResult = dataApiClient.Login(username, password), Throws.Nothing);
            Assert.That(authenticationResult.IsAuthenticated, Is.True);
            Assert.That(() => dataApiClient.DeleteUser(username), Throws.Nothing);
            dataApiClient.Logout();
            Assert.That(() => authenticationResult = dataApiClient.Login(username, password), Throws.Nothing);
            Assert.That(authenticationResult.IsAuthenticated, Is.False);
        }