Esempio 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);
            }
        }
Esempio n. 2
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"));
     }
 }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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");
            }
        }
 public void TearDown()
 {
     OptionApi.SetString("SendLinkServiceUrl", _restoreSendlinkUrl);
     OptionApi.SetString("SendLinkCloudStorageLoginName", _restoreSendlinkUser);
     OptionApi.SetString("SendLinkDeviceToken", _restoreSendlinkDeviceToken);
     _server.Dispose();
     _server = null;
     if (Directory.Exists(_tempDir))
     {
         foreach (var file in Directory.GetFiles(_tempDir))
         {
             File.Delete(file);
         }
         Directory.Delete(_tempDir);
     }
 }
        public void Setup()
        {
            int port = 4444;
            _server = new UnitTestSkyDoxServer(port);
            _restoreSendlinkUrl = OptionApi.GetString("SendLinkServiceUrl");
            _restoreSendlinkUser = OptionApi.GetString("SendLinkCloudStorageLoginName");
            _restoreSendlinkDeviceToken = OptionApi.GetString("SendLinkDeviceToken");
            OptionApi.SetString("SendLinkServiceUrl", "http://localhost:" + port);

            _tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            if (Directory.Exists(_tempDir))
            {
                foreach (var file in Directory.GetFiles(_tempDir))
                {
                    File.Delete(file);
                }
                Directory.Delete(_tempDir);
            }
            Directory.CreateDirectory(_tempDir);
        }
Esempio n. 8
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);
            }
        }