Exemplo n.º 1
0
        public void TestCreateSessionFromPassword()
        {
            using (var _server = new UnitTestSkyDoxServer(1344))
            {
                _server.NextResponse.Enqueue(MockResponse.user_sessions_SuccessDeviceTokenValidated);

                DoxApi doxApi = new DoxApi(_apiUrl);
                string user = string.Format(_rootEmail, "validated-personal");
                var session = doxApi.CreateSessionFromPassword(user, "Workshare1", null);
                Assert.NotNull(session);
                Assert.IsNotNullOrEmpty(session.Credentials.DeviceToken);
            }
        }
Exemplo n.º 2
0
        public void TestSetCredentialsForUserThatAlreadyExistsButIsntValidated()
        {
            using (var _server = new UnitTestSkyDoxServer(1344))
            {
                _server.NextResponse.Enqueue(MockResponse.sign_ups_Success);

                DoxApi doxApi = new DoxApi(_apiUrl);
                string user = string.Format(_rootEmail, "unvalidated-personal");
                string password = "******";

                Assert.True(doxApi.SetCredentials(user, password, null));
                Assert.Null(doxApi.Error);
            }
        }
Exemplo n.º 3
0
        public void TestRegisterNonExistantUser()
        {
            using (var _server = new UnitTestSkyDoxServer(1344))
            {
                _server.NextResponse.Enqueue(MockResponse.sign_ups_Success);

                DoxApi doxApi = new DoxApi(_apiUrl);
                string user = string.Format(_rootEmail, Guid.NewGuid().ToString("N"));
                string password = "******";

                Assert.True(doxApi.RegisterUser(user, password, null));
                Assert.Null(doxApi.Error);
            }
        }
Exemplo n.º 4
0
        //[Test]
        public void TestSignupAsAUserThatAlreadyExistsAndIsValidated()
        {
            using (var _server = new UnitTestSkyDoxServer(1344))
            {
                _server.NextResponse.Enqueue(MockResponse.sign_ups_UserAlreadyExists);

                DoxApi doxApi = new DoxApi(_apiUrl);
                string user = string.Format(_rootEmail, "validated-personal");
                string password = "******";

                Assert.False(doxApi.RegisterUser(user, password, null));
                Assert.NotNull(doxApi.Error);
                Assert.AreEqual(doxApi.Error.HttpStatus, 409);
                Assert.AreEqual(doxApi.Error.Message, "Email address already registered");
            }
        }
Exemplo n.º 5
0
 //[Test]
 public void TestCreateSessionFromPassword_UnvalidatedUser_Before()
 {
     using (var _server = new UnitTestSkyDoxServer(1344))
     {
         _server.NextResponse.Enqueue(MockResponse.user_sessions_Unvalidated);
         DoxApi doxApi = new DoxApi(_apiUrl);
         string user = string.Format(_rootEmail, "unvalidated-personal");
         var session = doxApi.CreateSessionFromPassword(user, "Workshare1", null);
         Assert.IsNull(session);
         Assert.NotNull(doxApi.Error);
         Assert.NotNull(doxApi.Error.Message);
         Assert.True(doxApi.Error.Message.Contains("hasn't been validated yet"));
     }
 }
Exemplo n.º 6
0
        public void TestCreateSessionFromDeviceToken_Unvalidated_After()
        {
            using (var _server = new UnitTestSkyDoxServer(1344))
            {
                DoxApi doxApi = new DoxApi(_apiUrl);
                _server.NextResponse.Enqueue(MockResponse.user_sessions_SuccessDeviceTokenUnvalidated);
                _server.NextResponse.Enqueue(MockResponse.current_user_NotValidated);

                string user = string.Format(_rootEmail, "unvalidated-personal");

                ApiHelper apiHelper = new ApiHelper();
                var session = doxApi.CreateSessionFromPassword(user, "Workshare1", apiHelper);
                Assert.IsNotNullOrEmpty(session.Credentials.DeviceToken);

                session = doxApi.CreateSessionFromDeviceToken(user, session.Credentials.DeviceToken, apiHelper);
                Assert.NotNull(session);
            }
        }