Ejemplo n.º 1
0
        public void SetUpBase()
        {
            var request = new GetAuthentication(new UserCredentials(Credentials.USERNAME, Credentials.API_KEY));
            var response = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(request));

            storageUrl = response.Headers[Constants.XStorageUrl];
            authToken = response.Headers[Constants.XAuthToken];
            Assert.That(authToken.Length, Is.EqualTo(36));
            connection = new Connection(new UserCredentials(Credentials.USERNAME, Credentials.API_KEY));
            SetUp();
        }
        public void Should_get_401_response_when_authenticated_incorrectly()
        {
            request =
                new GetAuthentication(new UserCredentials("EPIC", "FAIL"));

            try
            {
                factory.Submit(request, null);
                Assert.Fail("Should throw WebException");
            }
            catch (WebException we)
            {
                //It's a protocol error that is usually a result of a 401 (Unauthorized)
                //Still trying to figure way to get specific httpstatuscode
                Assert.That(((HttpWebResponse) we.Response).StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));
            }
        }
Ejemplo n.º 3
0
        public void SetUpBase()
        {
            var credentials = new UserCredentials(new Uri(Credentials.AUTH_ENDPOINT), Credentials.USERNAME,Credentials.API_KEY);
            var request = new GetAuthentication(credentials);
            var cfrequest = new CloudFilesRequest((HttpWebRequest) WebRequest.Create(request.CreateUri()));
            request.Apply(cfrequest);
            var response =
                new ResponseFactory().Create(cfrequest);

            storageUrl = response.Headers[Constants.XStorageUrl];
            authToken = response.Headers[Constants.XAuthToken];
            connection = new Connection(credentials);

            if (!connection.HasCDN()) Assert.Ignore("Provider does not support CDN Management");

            SetUp();
        }
Ejemplo n.º 4
0
        public void SetUpBase()
        {
            Uri uri = new Uri(Constants.AUTH_URL);

            GetAuthentication request =
                new GetAuthentication(
                    new UserCredentials(
                        uri,
                        Constants.CREDENTIALS_USER_NAME,
                        Constants.CREDENTIALS_PASSWORD,
                        Constants.CREDENTIALS_CLOUD_VERSION,
                        Constants.CREDENTIALS_ACCOUNT_NAME));

            IResponse response = new GenerateRequestByType().Submit(request, authToken);
                ;

            storageUrl = response.Headers[utils.Constants.X_STORAGE_URL];
            authToken = response.Headers[utils.Constants.X_AUTH_TOKEN];
            Assert.That(authToken.Length, Is.EqualTo(32));
            SetUp();
        }
Ejemplo n.º 5
0
        void authenticatesequence()
        {
            var getAuthentication = new GetAuthentication(_usercreds);
            var getAuthenticationResponse = _requestfactory.Submit(getAuthentication);
            // var getAuthenticationResponse = getAuthentication.Apply(request);

            if (getAuthenticationResponse.Status == HttpStatusCode.NoContent)
            {
                StorageUrl = getAuthenticationResponse.Headers[Constants.X_STORAGE_URL];
                AuthToken = getAuthenticationResponse.Headers[Constants.X_AUTH_TOKEN];
                CdnManagementUrl = getAuthenticationResponse.Headers[Constants.X_CDN_MANAGEMENT_URL];
                return;
            }

            if (!retry && getAuthenticationResponse.Status == HttpStatusCode.Unauthorized)
            {
                retry = true;
                Authenticate();
                return;
            }
        }
 public void setup()
 {
     var userCredentials = new UserCredentials("username", "apikey");
     getAuthentication = new GetAuthentication(userCredentials);
 }
 public void setup()
 {
     var userCredentials = new UserCredentials(new Uri("http://authurl"), "username", "apikey", "cloudversion", "cloudaccountname");
     getAuthentication = new GetAuthentication(userCredentials);
 }
        public void Should_replace_plus_sign_with_percent_20_on_account_name_username_and_password()
        {
            UserCredentials userCredentials = new UserCredentials(new Uri("http://tempuri"), "user name", "pass word", "v 1", "account name");
            GetAuthentication getAuthentication = new GetAuthentication(userCredentials);

            Assert.That(getAuthentication.Uri.AbsoluteUri, Is.EqualTo("http://tempuri//v%201/account%20name/auth"));
            Assert.That(getAuthentication.Headers[utils.Constants.X_AUTH_USER], Is.EqualTo("user%20name"));
            Assert.That(getAuthentication.Headers[utils.Constants.X_AUTH_KEY], Is.EqualTo("pass%20word"));
        }
 public void Setup()
 {
     request =
         new GetAuthentication(new UserCredentials(Credentials.USERNAME, Credentials.API_KEY));
     factory = new GenerateRequestByType();
 }
 public void setup()
 {
     var userCredentials = new UserCredentials("username", "apikey");
     getAuthentication = new GetAuthentication(userCredentials);
     _mockrequest = new Mock<ICloudFilesRequest>();
 }
 public void setup()
 {
     var userCredentials = new UserCredentials(new Uri("http://authurl"), "username", "apikey", "cloudversion", "cloudaccountname");
     getAuthentication = new GetAuthentication(userCredentials);
     _mockrequest = new Mock<ICloudFilesRequest>();
 }
 public void Should_replace_plus_sign_with_percent_20_on_account_name_username_and_password()
 {
     UserCredentials userCreds = new UserCredentials(new Uri("http://tempuri"), "user name", "pass word", "v 1", "account name");
     GetAuthentication getAuthentication = new GetAuthentication(userCreds);
     var _mockrequest = new Mock<ICloudFilesRequest>();
     var headers = new WebHeaderCollection();
     _mockrequest.SetupGet(x => x.Headers).Returns(headers);
     getAuthentication.Apply(_mockrequest.Object);
     Assert.That(getAuthentication.CreateUri().AbsoluteUri, Is.EqualTo("http://tempuri//v%201/account%20name/auth"));
     Assert.That(headers[utils.Constants.X_AUTH_USER], Is.EqualTo("user%20name"));
     Assert.That(headers[utils.Constants.X_AUTH_KEY], Is.EqualTo("pass%20word"));
 }
Ejemplo n.º 13
0
        private void Authenticate()
        {
            Log.Info(this, "Authenticating user " + UserCredentials.Username);
            try
            {
                var getAuthentication = new GetAuthentication(UserCredentials);
                var getAuthenticationResponse = new ResponseFactory<CloudFilesResponse>().Create(new CloudFilesRequest(getAuthentication, UserCredentials.ProxyCredentials));
                if (getAuthenticationResponse.Status == HttpStatusCode.NoContent)
                {
                    StorageUrl = getAuthenticationResponse.Headers[Constants.X_STORAGE_URL];
                    AuthToken = getAuthenticationResponse.Headers[Constants.X_AUTH_TOKEN];
                    CdnManagementUrl = getAuthenticationResponse.Headers[Constants.X_CDN_MANAGEMENT_URL];
                    return;
                }

                if (!retry && getAuthenticationResponse.Status == HttpStatusCode.Unauthorized)
                {
                    retry = true;
                    Authenticate();
                    return;
                }
            }
            catch(Exception ex)
            {
                Log.Error(this, "Error authenticating user " + UserCredentials.Username, ex);
                throw;
            }
        }
 public void Setup()
 {
     request =
         new GetAuthentication(new UserCredentials(Credentials.USERNAME, Credentials.API_KEY));
 }