Example #1
0
        static void Main()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            DracoonAuth dracoonAuth = new DracoonAuth(ACCESS_TOKEN);
            IWebProxy   wp          = WebRequest.GetSystemWebProxy();

            wp.Credentials = CredentialCache.DefaultNetworkCredentials;
            DracoonHttpConfig config = new DracoonHttpConfig(retryEnabled: true, webProxy: wp);

            dc = new DracoonClient(SERVER_URI, dracoonAuth, ENCRYPTION_PASSWORD, new Logger(), config);
        }
Example #2
0
        internal static RestRequest RestRequestWithoutAuth(string apiPath, Method method)
        {
            DracoonHttpConfig config = new DracoonHttpConfig();
            RestRequest       r      = new RestRequest(apiPath, method)
            {
                ReadWriteTimeout = config.ReadWriteTimeout,
                Timeout          = config.ConnectionTimeout,
                Method           = method,
                Resource         = apiPath
            };

            return(r);
        }
Example #3
0
        internal static RestRequest RestRequestWithAuth(string apiPath, Method method)
        {
            DracoonHttpConfig config = new DracoonHttpConfig();
            RestRequest       r      = new RestRequest(apiPath, method)
            {
                ReadWriteTimeout = config.ReadWriteTimeout,
                Timeout          = config.ConnectionTimeout,
                Method           = method,
                Resource         = apiPath
            };

            r.AddHeader(ApiConfig.AuthorizationHeader, FactoryClients.OAuthMock.BuildAuthString());
            return(r);
        }
        public void Nodes_ProvideS3ChunkUploadWebClient()
        {
            // ARRANGE
            DracoonHttpConfig         conf     = new DracoonHttpConfig();
            IRequestBuilder           builder  = new DracoonRequestBuilder(FactoryClients.OAuthMock);
            DracoonWebClientExtension expected = new DracoonWebClientExtension();

            expected.Headers.Add(HttpRequestHeader.UserAgent, conf.UserAgent);
            expected.SetHttpConfigParams(conf);

            // ACT
            WebClient actual = builder.ProvideS3ChunkUploadWebClient();

            // ASSERT
            Assert.Equal(expected, actual, new WebClientComparer());
        }
        public void Nodes_ProvideChunkUploadWebClient()
        {
            // ARRANGE
            int                       length = 54637;
            long                      offset = 5;
            string                    data = "someDataThings!", fileSize = "123";
            DracoonHttpConfig         conf     = new DracoonHttpConfig();
            IRequestBuilder           builder  = new DracoonRequestBuilder(FactoryClients.OAuthMock);
            DracoonWebClientExtension expected = new DracoonWebClientExtension();

            expected.Headers.Add(HttpRequestHeader.ContentRange, "bytes " + offset + "-" + (offset + length) + "/" + fileSize);
            expected.Headers.Add(HttpRequestHeader.ContentType, "multipart/form-data; boundary=" + data);
            expected.Headers.Add(HttpRequestHeader.UserAgent, conf.UserAgent);
            expected.SetHttpConfigParams(conf);

            // ACT
            WebClient actual = builder.ProvideChunkUploadWebClient(length, offset, data, fileSize);

            // ASSERT
            Assert.Equal(expected, actual, new WebClientComparer());
        }
        public void DracoonClient_Ctor()
        {
            // ARRANGE
            Uri               expectedUri  = new Uri("https://dracoon.team");
            DracoonAuth       expectedAuth = new DracoonAuth("token");
            string            expectedEncryptionPassword = "******";
            EmptyLog          expectedLog    = new EmptyLog();
            DracoonHttpConfig expectedConfig = new DracoonHttpConfig(true);

            Mock.Arrange(() => Arg.IsAny <Uri>().MustBeValid(Arg.AnyString)).DoNothing().Occurs(1);

            // ACT
            DracoonClient          dc         = new DracoonClient(expectedUri, null, expectedEncryptionPassword, expectedLog, expectedConfig);
            IInternalDracoonClient dcInternal = dc;

            // ASSERT
            Assert.Equal(expectedUri, dc.ServerUri);
            Assert.Null(dc.Auth);
            dc.Auth = expectedAuth;
            Assert.Equal(expectedAuth, dc.Auth);
            Assert.Equal(expectedEncryptionPassword, dc.EncryptionPassword);
            Assert.Equal(expectedConfig, DracoonClient.HttpConfig);
            Assert.Equal(expectedLog, DracoonClient.Log);
            Assert.NotNull(dc.Nodes);
            Assert.NotNull(dc.Account);
            Assert.NotNull(dc.Server);
            Assert.NotNull(dc.Shares);
            Assert.NotNull(dc.Users);
            Assert.NotNull(dcInternal.Executor);
            Assert.NotNull(dcInternal.Builder);
            Assert.NotNull(dcInternal.OAuth);
            Assert.NotNull(dcInternal.NodesImpl);
            Assert.NotNull(dcInternal.AccountImpl);
            Assert.NotNull(dcInternal.ServerImpl);
            Assert.NotNull(dcInternal.SharesImpl);
            Assert.NotNull(dcInternal.UsersImpl);
            Mock.Assert(() => Arg.IsAny <Uri>().MustBeValid(Arg.AnyString));
        }
 public void SetHttpConfigParams(DracoonHttpConfig httpConfig)
 {
     _config = httpConfig;
 }