Ejemplo n.º 1
0
        public void ValidateSecureCredentialProviderSetter()
        {
            var credential = new Credentials
            {
                Password = "******"
            };

            var json = (string)credential.GetCustomSerializer(SerializerFormat.JSON);

            dynamic deserialized = SerializerFactory.GetCustomSerializer <DynamicSerialization>(SerializerFormat.JSON).Deserialize(json);

            var passwordEncrypted = (string)deserialized.Password;

            var credentialResult = new Credentials
            {
                PasswordInternal = passwordEncrypted
            };

            Assert.Equal(credential.Password, credentialResult.Password);
        }
Ejemplo n.º 2
0
        public void ValidateSecureCredentialProvider()
        {
            var credential = new Credentials
            {
                Password = "******",
                UserName = EnvironmentHelper.UserName
            };

            var json = (string)credential.GetCustomSerializer(SerializerFormat.JSON);

            dynamic deserialized = SerializerFactory.GetCustomSerializer <DynamicSerialization>(SerializerFormat.JSON).Deserialize(json);

            var passwordEncrypted = (string)deserialized.Password;

            passwordEncrypted = passwordEncrypted.Substring(0, passwordEncrypted.Length - 32);

            var secureCredentialProvider = ServiceLocator.Resolve <ISecureCredentialProvider>();

            var passwordDecrypted = passwordEncrypted.Decrypt(secureCredentialProvider.PasswordHash, secureCredentialProvider.SaltKey, secureCredentialProvider.IVKey);

            Assert.Equal(credential.Password, passwordDecrypted);

            Assert.Equal(credential.UserName, (string)deserialized.UserName);
        }