public void SetUp()
        {
            userCreds = new UserCredentials(new Uri(Credentials.AUTH_ENDPOINT), Credentials.USERNAME, Credentials.API_KEY);
            connection = new Connection(userCreds);

            account = connection.Account;
        }
        public void Setup()
        {
            var userCredentials = new UserCredentials(new Uri(Credentials.AUTH_ENDPOINT), Credentials.USERNAME, Credentials.API_KEY);

            connection = new Connection(userCredentials);
            account = connection.Account;
            container = account.CreateContainer(Constants.CONTAINER_NAME);
        }
        public void Should_instantiate_engine_without_throwing_exception_when_authentication_passes()
        {
            var userCreds = new UserCredentials(
                new Uri(Constants.AUTH_URL),
                Constants.CREDENTIALS_USER_NAME,
                Constants.CREDENTIALS_PASSWORD,
                Constants.CREDENTIALS_CLOUD_VERSION,
                Constants.CREDENTIALS_ACCOUNT_NAME);
            var conection = new MockConnection(userCreds);

            Assert.That(conection.AuthenticationSuccessful, Is.True);
        }
        public void SetUp()
        {
            authUrl = new Uri(Constants.AUTH_URL);

            proxyCredentials = new ProxyCredentials(Constants.PROXY_ADDRESS, Constants.PROXY_USERNAME, Constants.PROXY_PASSWORD, Constants.PROXY_DOMAIN);

            userCreds = new UserCredentials(
                authUrl,
                Constants.CREDENTIALS_USER_NAME,
                Constants.CREDENTIALS_PASSWORD,
                Constants.CREDENTIALS_CLOUD_VERSION,
                Constants.CREDENTIALS_ACCOUNT_NAME,
                proxyCredentials
                );
        }
        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();
        }
        public static void Main(string[] args)
        {
            Boolean b = false;

            if (args.Length != 4) {
                Console.WriteLine("Usage: username api_key container object");
                Environment.Exit(1);
            }

            username = args[0];
            api_key = args[1];
            chosenContainer = args[2];
            filePath = args[3];

            UserCredentials userCreds = new UserCredentials(username, api_key, AuthUrl.UK);
            Connection connection = new Connection(userCreds);

            List<string> containers = connection.GetContainers();

            foreach (string container in containers) {
                if (container == chosenContainer)
                    b = true;
            }

            if (!b) {
                Console.WriteLine("Container {0} does not seem to exist.", chosenContainer);
                Environment.Exit(1);
            }

            if (!File.Exists(filePath)) {
                Console.WriteLine("fileName {0} does not seem to exist.", filePath);
                Environment.Exit(1);
            }

            FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            connection.PutStorageItem(chosenContainer, fileStream, Path.GetFileName(filePath));
            Console.WriteLine("*success* uploaded");
        }
        public void Setup()
        {
            proxyCredentials = new ProxyCredentials(Constants.PROXY_ADDRESS, Constants.PROXY_USERNAME, Constants.PROXY_PASSWORD, Constants.PROXY_DOMAIN);

            userCreds = new UserCredentials(
                Constants.CREDENTIALS_USER_NAME,
                Constants.CREDENTIALS_PASSWORD,
                proxyCredentials
                );
        }
 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[CloudFiles.Utils.Constants.X_AUTH_USER], Is.EqualTo("user%20name"));
     Assert.That(headers[CloudFiles.Utils.Constants.X_AUTH_KEY], Is.EqualTo("pass%20word"));
 }
Beispiel #11
0
        public Connection(UserCredentials userCreds, bool useServiceNet)
        {
            // configure the timer to be disabled
            // note, that when the _reInitAuthSequence is called from the timer
            // we always pass true for the retry.
            _reAuthenticateTimer = new Timer( (c) => {_reInitAuthSequence(true);}, null, System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);

            _authenticationPending = 0;
            _useServiceNet = useServiceNet;
            _requestfactory = new GenerateRequestByType();
            _callbackFuncs = new List<ProgressCallback>();
            Log.EnsureInitialized();

            if (userCreds == null) throw new ArgumentNullException("userCreds");

            _usercreds = userCreds;

            VerifyAuthentication();
        }
Beispiel #12
0
 /// <summary>
 /// A constructor used to create an instance of the Connection class
 /// </summary>
 /// <example>
 /// <code>
 /// UserCredentials userCredentials = new UserCredentials("username", "api key");
 /// IConnection connection = new Connection(userCredentials);
 /// </code>
 /// </example>
 /// <param name="userCreds">An instance of the UserCredentials class, containing all pertinent authentication information</param>
 /// <exception cref="ArgumentNullException">Thrown when any of the reference parameters are null</exception>
 public Connection(UserCredentials userCreds)
     : this(userCreds, false)
 {
 }
        public Connection(UserCredentials userCreds, bool useServiceNet)
        {
            _useServiceNet = useServiceNet;
            _requestfactory = new GenerateRequestByType();
            _callbackFuncs = new List<ProgressCallback>();
            Log.EnsureInitialized();

            if (userCreds == null) throw new ArgumentNullException("userCreds");

            _usercreds = userCreds;

            VerifyAuthentication();
        }
 public MockConnection(UserCredentials userCreds)
     : base(userCreds)
 {
 }