Пример #1
0
        public void TestThatUnencryptedJsonIsNotIdentifiedAsEncrypted()
        {
            var crypto = new JsonConfigCrypto(_cryptoKey);

            Assert.That(crypto.IsEncrypted(_json), Is.False);
            Assert.That(crypto.IsEncrypted(_tiersJson), Is.False);
        }
Пример #2
0
        public void TestThatEncryptedJsonCanBeDecryptedIntoTypedConfig()
        {
            //var parser = new EnvConfigParser(new ConfigJsonSerializer(new JsonConfigCrypto()), new JsonConfigCrypto());
            var cryptoHandler = new JsonConfigCrypto(_cryptoKey);
            var serializer    = new ConfigJsonSerializer(cryptoHandler);

            //parser.Encrypted(_json, out config);
            var config = serializer.DeSerialize(_json);

            string deploymentPassword = config.DeploymentUser.Password;
            string lbPassword         = config.LoadBalancer.Password;

            var encryptedJson = cryptoHandler.Encrypt(_json);

            //parser.EncryptJsonConfig(config, crypto);

            //var encryptedJson = parser.ConvertToJsonText(config);
            Assert.That(cryptoHandler.IsEncrypted(encryptedJson), Is.True);

            var decryptedConfig = serializer.DeSerialize(encryptedJson);

            Assert.That(decryptedConfig.DeploymentUser.Password, Is.EqualTo(deploymentPassword));
            Assert.That(decryptedConfig.LoadBalancer.Password, Is.EqualTo(lbPassword));
        }