Ejemplo n.º 1
0
        public void SetUp()
        {
            userCreds = new UserCredentials(Credentials.USERNAME, Credentials.API_KEY);
            connection = new Connection(userCreds);

            account = connection.Account;
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public void Should_instantiate_engine_without_throwing_exception_when_authentication_passes()
        {
            UserCredentials userCredentials = new UserCredentials(new Uri(Constants.AUTH_URL), Constants.CREDENTIALS_USER_NAME, Constants.CREDENTIALS_PASSWORD, Constants.CREDENTIALS_CLOUD_VERSION, Constants.CREDENTIALS_ACCOUNT_NAME);

            MockConnection conection = new MockConnection(userCredentials);

            Assert.That(conection.AuthenticationSuccessful, Is.True);
        }
Ejemplo n.º 4
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="userCredentials">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 userCredentials)
        {
            callbackFuncs = new List<ProgressCallback>();
            Log.EnsureInitialized();
            AuthToken = "";
            StorageUrl = "";
            if (userCredentials == null) throw new ArgumentNullException("userCredentials");

            UserCredentials = userCredentials;
            VerifyAuthentication();
        }
Ejemplo n.º 5
0
        public Connection(UserCredentials userCreds)
        {
            _requestfactory = new GenerateRequestByType();
            callbackFuncs = new List<ProgressCallback>();
            Log.EnsureInitialized();
            AuthToken = "";
            StorageUrl = "";
            if (userCreds == null) throw new ArgumentNullException("userCredentials");

            _usercreds = userCreds;

            VerifyAuthentication();
        }
        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
                );
        }
Ejemplo n.º 7
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.º 8
0
        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);
            Connection connection = new com.mosso.cloudfiles.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()
 {
     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()
        {
            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
                );
        }
Ejemplo n.º 12
0
        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 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"));
 }
 public void setup()
 {
     var userCredentials = new UserCredentials("username", "apikey");
     getAuthentication = new GetAuthentication(userCredentials);
 }
Ejemplo n.º 17
0
 public MockConnection(UserCredentials userCredentials)
     : base(userCredentials)
 {
 }
Ejemplo n.º 18
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)
 {
 }