Ejemplo n.º 1
0
        public void TestConnectionWrapperCheckValuesAre()
        {
            var wrapper = new ConnectionWrapper();
            Mock <IConfiguration>    mockAStorage = new Mock <IConfiguration>();
            APIConnectionInformation info         = new APIConnectionInformation();

            info.Token            = "Token";
            info.ApiUri           = "https://apiuri.com";
            info.StorageUri       = "https://storageuri.com";
            info.AccountEmail     = "*****@*****.**";
            info.ForcePathStyle   = true;
            info.StorageUnsafeSsl = true;
            mockAStorage.Setup(foo => foo.ApiConnection).Returns(info);

            IConfiguration config = mockAStorage.Object;

            QarnotSDK.Connection connection = wrapper.CreateConnection(config);

            Assert.AreEqual("Token", connection.Token);
            Assert.AreEqual(new Uri("https://apiuri.com/"), connection.Uri);
            Assert.AreEqual(new Uri("https://storageuri.com/"), connection.StorageUri);
            Assert.AreEqual(true, connection.ForceStoragePathStyle);
            Assert.AreEqual("*****@*****.**", connection.StorageAccessKey);
            Assert.IsInstanceOf <UnsafeS3HttpClientFactory>(connection.S3HttpClientFactory);
        }
Ejemplo n.º 2
0
            public void RetrieveEnvironmentInformation(APIConnectionInformation api)
            {
                if (EnvToken)
                {
                    api.SetToken = "token_env";
                }

                if (EnvApi)
                {
                    api.SetApiUri = "api_env";
                }

                if (EnvStorage)
                {
                    api.SetStorageUri = "storage_env";
                }

                if (EnvEmail)
                {
                    api.SetAccountEmail = "email_env";
                }

                if (EnvStorage)
                {
                    api.SetForcePathStyle = true;
                }
            }
Ejemplo n.º 3
0
        public void CheckInfoWellSendToTheWriter()
        {
            LocalSetUpConfiguration  config = new LocalSetUpConfiguration();
            APIConnectionInformation connectionInformation = new APIConnectionInformation();

            connectionInformation.Token          = "token123";
            connectionInformation.ApiUri         = "uri123";
            connectionInformation.StorageUri     = "bucket123";
            connectionInformation.AccountEmail   = "email123";
            connectionInformation.ForcePathStyle = false;
            connectionInformation.DisableBucketPathsSanitization = false;
            connectionInformation.UnsafeSsl        = true;
            connectionInformation.StorageUnsafeSsl = true;
            config.ApiConnection = connectionInformation;

            Set.SetConfigInformation("path123", config);

            Assert.AreEqual(FileWrap.PathFind, "path123");
            Assert.AreEqual(Writer.Checker["token"], "token123");
            Assert.AreEqual(Writer.Checker["uri"], "uri123");
            Assert.AreEqual(Writer.Checker["account-email"], "email123");
            Assert.AreEqual(Writer.Checker["force-path"], "False");
            Assert.AreEqual(Writer.Checker["disable-path-sanitization"], "False");
            Assert.AreEqual(Writer.Checker["unsafe-ssl"], "True");
            Assert.AreEqual(Writer.Checker["storage-unsafe-ssl"], "True");
        }
Ejemplo n.º 4
0
        public void TestTokenSetBeforeNoEnvVarAddFileUris()
        {
            FakeGetEnvConnectionInformation fakeGetEnvConnectionInformation = new FakeGetEnvConnectionInformation(false, false, false);
            FakeEnvironmentPathGetter       fakeEnvironmentPathGetter       = new FakeEnvironmentPathGetter();
            FakeFileInformationGetter       fakeFileInformationGetter       = new FakeFileInformationGetter();
            var ret = new ApiConnectionConfigurationRetriever(fakeEnvironmentPathGetter, fakeGetEnvConnectionInformation, fakeFileInformationGetter);
            var api = new APIConnectionInformation()
            {
                Token             = "token0",
                ApiUri            = null,
                StorageUri        = null,
                SetForcePathStyle = null,
                SetDisableBucketPathsSanitization = null,
                SetUnsafeSsl        = null,
                SetStorageUnsafeSsl = null
            };

            ret.RetrieveConfigurationInformation(api);
            Assert.AreEqual(api.Token, "token0");
            Assert.AreEqual(api.ApiUri, "api_file");
            Assert.AreEqual(api.StorageUri, "storage_file");
            Assert.AreEqual(api.ForcePathStyle, false);
            Assert.AreEqual(api.GetForcePathStyle, null);
            Assert.AreEqual(false, api.DisableBucketPathsSanitization);
            Assert.AreEqual(null, api.GetDisableBucketPathsSanitization);
            Assert.AreEqual(false, api.UnsafeSsl);
            Assert.AreEqual(null, api.GetUnsafeSsl);
            Assert.AreEqual(false, api.StorageUnsafeSsl);
            Assert.AreEqual(null, api.GetStorageUnsafeSsl);
        }
Ejemplo n.º 5
0
        public void GetValueTestStorageUnsafeSsl()
        {
            APIConnectionInformation apiInformation = new APIConnectionInformation();
            string line = "storage-unsafe-ssl=true";

            var fileinfo = new ConfigurationFileReader();

            fileinfo.GetValue(line, apiInformation);
            Assert.AreEqual(apiInformation.StorageUnsafeSsl, true);
        }
Ejemplo n.º 6
0
        public void GetValueTestDisableBucketPathSanitization()
        {
            APIConnectionInformation apiInformation = new APIConnectionInformation();
            string line = "disable-path-sanitization=true";

            var fileinfo = new ConfigurationFileReader();

            fileinfo.GetValue(line, apiInformation);
            Assert.AreEqual(apiInformation.DisableBucketPathsSanitization, true);
        }
Ejemplo n.º 7
0
        public void GetValueAccountEmail()
        {
            APIConnectionInformation apiInformation = new APIConnectionInformation();
            string line = "[email protected]";

            var fileinfo = new ConfigurationFileReader();

            fileinfo.GetValue(line, apiInformation);
            Assert.AreEqual(apiInformation.AccountEmail, "*****@*****.**");
        }
Ejemplo n.º 8
0
        public void GetValueTestForcePathStyle()
        {
            APIConnectionInformation apiInformation = new APIConnectionInformation();
            string line = "force-path=true";

            var fileinfo = new ConfigurationFileReader();

            fileinfo.GetValue(line, apiInformation);
            Assert.AreEqual(apiInformation.ForcePathStyle, true);
        }
Ejemplo n.º 9
0
        public void GetValueTestSplitAStorageLine()
        {
            APIConnectionInformation apiInformation = new APIConnectionInformation();
            string line = "storage=TOKEN123";

            var fileinfo = new ConfigurationFileReader();

            fileinfo.GetValue(line, apiInformation);
            Assert.AreEqual(apiInformation.StorageUri, "TOKEN123");
        }
Ejemplo n.º 10
0
            public APIConnectionInformation ReadFile(string filePath)
            {
                var api = new APIConnectionInformation()
                {
                    Token        = "token_file",
                    ApiUri       = "api_file",
                    StorageUri   = "storage_file",
                    AccountEmail = "email_file",
                };

                return(api);
            }
            public APIConnectionInformation ReadFile(string filePath)
            {
                var api = new APIConnectionInformation();

                api.Token          = Token;
                api.ApiUri         = ApiUri;
                api.StorageUri     = StorageUri;
                api.AccountEmail   = AccountEmail;
                api.ForcePathStyle = ForcePath.Value;
                api.DisableBucketPathsSanitization = DisableSanitization.Value;
                return(api);
            }
Ejemplo n.º 12
0
        public void TestNoEnvVarSet()
        {
            var fakeGetEnvConnectionInformation = new FakeGetEnvConnectionInformation(false, false, false);
            FakeEnvironmentPathGetter fakeEnvironmentPathGetter = new FakeEnvironmentPathGetter();
            FakeFileInformationGetter fakeFileInformationGetter = new FakeFileInformationGetter();
            var ret = new ApiConnectionConfigurationRetriever(fakeEnvironmentPathGetter, fakeGetEnvConnectionInformation, fakeFileInformationGetter);
            var api = new APIConnectionInformation()
            {
                Token      = null,
                ApiUri     = null,
                StorageUri = null,
            };

            ret.RetrieveConfigurationInformation(api);
            Assert.AreEqual(api.Token, "token_file");
            Assert.AreEqual(api.ApiUri, "api_file");
            Assert.AreEqual(api.StorageUri, "storage_file");
        }
Ejemplo n.º 13
0
        public void TestAllEnvVarSet()
        {
            var fakeGetEnvConnectionInformation = new FakeGetEnvConnectionInformation(true, true, true, envUnsafe: true, envStorageUnsafe: true);
            FakeEnvironmentPathGetter fakeEnvironmentPathGetter = new FakeEnvironmentPathGetter();
            FakeFileInformationGetter fakeFileInformationGetter = new FakeFileInformationGetter();
            var ret = new ApiConnectionConfigurationRetriever(fakeEnvironmentPathGetter, fakeGetEnvConnectionInformation, fakeFileInformationGetter);
            var api = new APIConnectionInformation()
            {
                Token             = null,
                ApiUri            = null,
                StorageUri        = null,
                SetForcePathStyle = null,
            };

            ret.RetrieveConfigurationInformation(api);
            Assert.AreEqual(api.Token, "token_env");
            Assert.AreEqual(api.ApiUri, "api_env");
            Assert.AreEqual(api.StorageUri, "storage_env");
            Assert.AreEqual(api.ForcePathStyle, true);
            Assert.AreEqual(api.UnsafeSsl, true);
            Assert.AreEqual(api.StorageUnsafeSsl, true);
        }
Ejemplo n.º 14
0
        public void TestUriEnvVarSet()
        {
            var fakeGetEnvConnectionInformation = new FakeGetEnvConnectionInformation(false, true, false);
            FakeEnvironmentPathGetter fakeEnvironmentPathGetter = new FakeEnvironmentPathGetter();
            FakeFileInformationGetter fakeFileInformationGetter = new FakeFileInformationGetter();
            var ret = new ApiConnectionConfigurationRetriever(fakeEnvironmentPathGetter, fakeGetEnvConnectionInformation, fakeFileInformationGetter);
            var api = new APIConnectionInformation()
            {
                Token          = null,
                ApiUri         = null,
                StorageUri     = null,
                AccountEmail   = null,
                ForcePathStyle = false,
            };

            ret.RetrieveConfigurationInformation(api);
            Assert.AreEqual(api.Token, "token_file");
            Assert.AreEqual(api.ApiUri, "api_env");
            Assert.AreEqual(api.StorageUri, "storage_file");
            Assert.AreEqual(api.AccountEmail, "email_file");
            Assert.AreEqual(api.ForcePathStyle, false);
            Assert.AreEqual(api.GetForcePathStyle, false);
        }
Ejemplo n.º 15
0
 public APIConnectionInformation RetrieveConfigurationInformation(APIConnectionInformation config)
 {
     GetIsCall = true;
     return(config);
 }