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")); }
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)); }
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")); }
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); }
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>")); }
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")); }
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); }
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); }