예제 #1
0
        public void SerializedXmlDoesNotContainPlaintextData()
        {
            SerializeableCloudStorageCredentials credentials = CreateExampleCredentials();

            credentials.EncryptBeforeSerialization(PseudoEncrypt);

            string xml = SerializeWithXmlSerializer(credentials);

            Assert.IsFalse(xml.Contains("atk"));
            Assert.IsFalse(xml.Contains("rtk"));
            Assert.IsFalse(xml.Contains("usr"));
            Assert.IsFalse(xml.Contains("pwd"));
        }
예제 #2
0
        public void SerializedDatacontractCanBeReadBack()
        {
            SerializeableCloudStorageCredentials credentials = CreateExampleCredentials();

            credentials.EncryptBeforeSerialization(PseudoEncrypt);
            string xml = SerializeWithDatacontract(credentials);

            var credentials2 = DeserializeWithDatacontract <SerializeableCloudStorageCredentials>(xml);

            credentials2.DecryptAfterDeserialization(PseudoDecrypt);

            Assert.IsTrue(credentials.AreEqualOrNull(credentials2));
        }
예제 #3
0
        public void SerializedJsonDoesNotContainPlaintextData()
        {
            SerializeableCloudStorageCredentials credentials = CreateExampleCredentials();

            credentials.EncryptBeforeSerialization(PseudoEncrypt);

            string json = JsonConvert.SerializeObject(credentials);

            Assert.IsFalse(json.Contains("atk"));
            Assert.IsFalse(json.Contains("rtk"));
            Assert.IsFalse(json.Contains("usr"));
            Assert.IsFalse(json.Contains("pwd"));
        }
예제 #4
0
        public void EncryptBeforeSerializationRespectsNullProperties()
        {
            var credentials = new SerializeableCloudStorageCredentials();

            credentials.EncryptBeforeSerialization(PseudoEncrypt);

            // The Serialization* are set and are not plaintext
            Assert.IsNull(credentials.SerializeableAccessToken);
            Assert.IsNull(credentials.SerializeableExpiryDate);
            Assert.IsNull(credentials.SerializeableRefreshToken);
            Assert.IsNull(credentials.SerializeableUsername);
            Assert.IsNull(credentials.SerializeablePassword);
            Assert.IsNull(credentials.SerializeableUrl);
        }
예제 #5
0
        public void SerializedDatacontractDoesNotContainNullProperties()
        {
            var credentials = new SerializeableCloudStorageCredentials();

            credentials.EncryptBeforeSerialization(PseudoEncrypt);

            string xml = SerializeWithDatacontract(credentials);

            Assert.IsFalse(xml.Contains("<access_token>"));
            Assert.IsFalse(xml.Contains("<refresh_token>"));
            Assert.IsFalse(xml.Contains("<username>"));
            Assert.IsFalse(xml.Contains("<password>"));
            Assert.IsFalse(xml.Contains("<url>"));
            Assert.IsFalse(xml.Contains("<secure>"));
        }
예제 #6
0
        public void SerializedJsonDoesNotContainNullProperties()
        {
            var credentials = new SerializeableCloudStorageCredentials();

            credentials.EncryptBeforeSerialization(PseudoEncrypt);

            string json = JsonConvert.SerializeObject(credentials);

            Assert.IsFalse(json.Contains("access_token"));
            Assert.IsFalse(json.Contains("refresh_token"));
            Assert.IsFalse(json.Contains("username"));
            Assert.IsFalse(json.Contains("password"));
            Assert.IsFalse(json.Contains("url"));
            Assert.IsFalse(json.Contains("secure"));
        }
예제 #7
0
        public void EncryptBeforeSerializationProtectsAllNecessaryProperties()
        {
            SerializeableCloudStorageCredentials credentials = CreateExampleCredentials();

            credentials.EncryptBeforeSerialization(PseudoEncrypt);

            // The Serialization* are set and are not plaintext
            Assert.IsNotNull(credentials.SerializeableAccessToken);
            Assert.IsNotNull(credentials.SerializeableExpiryDate);
            Assert.IsNotNull(credentials.SerializeableRefreshToken);
            Assert.IsNotNull(credentials.SerializeableUsername);
            Assert.IsNotNull(credentials.SerializeablePassword);
            Assert.IsNotNull(credentials.SerializeableUrl);
            Assert.IsNotNull(credentials.SerializeableSecure);
            Assert.AreNotEqual(credentials.Token.AccessToken, credentials.SerializeableAccessToken);
            Assert.AreNotEqual(credentials.Token.RefreshToken, credentials.SerializeableRefreshToken);
            Assert.AreNotEqual(credentials.Username, credentials.SerializeableUsername);
            Assert.AreNotEqual(credentials.UnprotectedPassword, credentials.SerializeablePassword);
        }
예제 #8
0
        public void DecryptAfterDesrializationCanReadAllPropertiesBack()
        {
            SerializeableCloudStorageCredentials credentials = CreateExampleCredentials();

            credentials.EncryptBeforeSerialization(PseudoEncrypt);

            credentials.Token    = null;
            credentials.Username = null;
            credentials.Password = null;
            credentials.Url      = null;
            credentials.Secure   = false;

            credentials.DecryptAfterDeserialization(PseudoDecrypt);

            Assert.AreEqual("atk", credentials.Token.AccessToken);
            Assert.AreEqual(new DateTime(1999, 12, 24, 0, 0, 0, DateTimeKind.Utc), credentials.Token.ExpiryDate);
            Assert.AreEqual("rtk", credentials.Token.RefreshToken);
            Assert.AreEqual("usr", credentials.Username);
            Assert.AreEqual("pwd", credentials.UnprotectedPassword);
            Assert.IsTrue(credentials.Secure);
        }