private static void UseClient(DracoonClient client)
        {
            NodeList rootNodes = client.Nodes.GetNodes();

            foreach (Node current in rootNodes.Items)
            {
                Console.WriteLine("NodeId: " + current.Id + "; NodeName: " + current.Name);
            }
        }
Beispiel #2
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);
        }
        static void Main()
        {
            // Authorize client
            string authCode = AuthorizeClient();

            // Initialize dracoon client
            DracoonClient client = CreateClient(authCode);

            // Use client
            UseClient(client);

            // After first usage of client the access and refresh tokens are retrieved and can be persisted
            string accessToken  = client.Auth.AccessToken;
            string refreshToken = client.Auth.RefreshToken;

            // On next startup of your application you can then use the tokens for another initialization without users browser login
            client = CreateClient(accessToken, refreshToken);

            // Use client again with new initialization
            UseClient(client);
        }
        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));
        }