Example #1
0
        public void EncryptWithEmptyPropertiesOK()
        {
            // all of these objects should have null properties, this should not cause secret to blow up
            var secret = Guid.NewGuid().ToString("n");

            try
            {
                var generic = new GenericService();
                generic.Configuration["test"] = string.Empty;
                generic.Encrypt(secret);
                generic.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("generic failed with empty values");
            }

            try
            {
                var file = new FileService
                {
                    Path = string.Empty,
                };
                file.Encrypt(secret);
                file.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("file failed with empty values");
            }

            try
            {
                var luis = new LuisService
                {
                    SubscriptionKey = string.Empty,
                };
                luis.Encrypt(secret);
                luis.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("luis failed with empty values");
            }

            try
            {
                var dispatch = new DispatchService
                {
                    SubscriptionKey = string.Empty,
                };
                dispatch.Encrypt(secret);
                dispatch.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("dispatch failed with empty values");
            }

            try
            {
                var insights = new AppInsightsService
                {
                    InstrumentationKey = string.Empty,
                };
                insights.Encrypt(secret);
                insights.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("insights failed with empty values");
            }

            try
            {
                var bot = new BotService();
                bot.Encrypt(secret);
                bot.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("bot failed with empty values");
            }

            try
            {
                var cosmos = new CosmosDbService
                {
                    Key = string.Empty,
                };
                cosmos.Encrypt(secret);
                cosmos.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("cosmos failed with empty values");
            }

            try
            {
                var qna = new QnAMakerService
                {
                    SubscriptionKey = string.Empty,
                };
                qna.Encrypt(secret);
                qna.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("qna failed with empty values");
            }

            try
            {
                var blob = new BlobStorageService
                {
                    ConnectionString = string.Empty,
                };
                blob.Encrypt(secret);
                blob.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("blob failed with empty values");
            }

            try
            {
                var endpoint = new EndpointService
                {
                    AppPassword = string.Empty,
                };
                endpoint.Encrypt(secret);
                endpoint.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("endpoint failed with empty values");
            }
        }
Example #2
0
        public void EncryptWithNullPropertiesOK()
        {
            // all of these objects should have null properties, this should not cause secret to blow up
            var secret = Guid.NewGuid().ToString("n");

            try
            {
                var generic = new GenericService();
                generic.Encrypt(secret);
                generic.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("generic failed with empty values");
            }

            try
            {
                var file = new FileService();
                file.Encrypt(secret);
                file.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("file failed with empty values");
            }

            try
            {
                var luis = new LuisService();
                luis.Encrypt(secret);
                luis.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("luis failed with empty values");
            }

            try
            {
                var dispatch = new DispatchService();
                dispatch.Encrypt(secret);
                dispatch.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("dispatch failed with empty values");
            }

            try
            {
                var insights = new AppInsightsService();
                insights.Encrypt(secret);
                insights.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("insights failed with empty values");
            }

            try
            {
                var bot = new BotService();
                bot.Encrypt(secret);
                bot.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("bot failed with empty values");
            }

            try
            {
                var cosmos = new CosmosDbService();
                cosmos.Encrypt(secret);
                cosmos.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("cosmos failed with empty values");
            }

            try
            {
                var qna = new QnAMakerService();
                qna.Encrypt(secret);
                qna.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("qna failed with empty values");
            }

            try
            {
                var blob = new BlobStorageService();
                blob.Encrypt(secret);
                blob.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("blob failed with empty values");
            }

            try
            {
                var endpoint = new EndpointService();
                endpoint.Encrypt(secret);
                endpoint.Decrypt(secret);
            }
            catch (Exception)
            {
                Assert.Fail("endpoint failed with empty values");
            }
        }