예제 #1
0
        public void TestThatEncryptTagGetsEncrypted()
        {
            var crypto        = new JsonConfigCrypto(_cryptoKey);
            var encryptedJson = crypto.Encrypt(_encryptJson);

            var decryptedJson = crypto.Decrypt(encryptedJson);

            var serializer = new ConfigJsonSerializer(crypto);

            serializer.DeSerialize(decryptedJson);
        }
예제 #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));
        }