public void Encrypt_64CharKeyWithFilter_Success() { var settings = new ProjectSettingsProvider("projId", "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"); IDictionary <string, object> filter = new ExpandoObject(); filter.Add("property_name", "account_id"); filter.Add("operator", "eq"); filter.Add("property_value", 123); dynamic secOpsIn = new ExpandoObject(); secOpsIn.filters = new List <object>() { filter }; secOpsIn.allowed_operations = new List <string>() { "read" }; Assert.DoesNotThrow(() => { var scopedKey = ScopedKey.Encrypt(settings.MasterKey, (object)secOpsIn); var decrypted = ScopedKey.Decrypt(settings.MasterKey, scopedKey); var secOpsOut = JObject.Parse(decrypted); Assert.True(secOpsIn.allowed_operations[0] == (string)(secOpsOut["allowed_operations"].First())); }); }
public void RoundTrip_PopulatedObject_WithIV_Success() { var settings = new ProjectSettingsProviderEnv(); var IV = "C0FFEEC0FFEEC0FFEEC0FFEEC0FFEEC0"; IDictionary <string, object> filter = new ExpandoObject(); filter.Add("property_name", "account_id"); filter.Add("operator", "eq"); filter.Add("property_value", 123); dynamic secOpsIn = new ExpandoObject(); secOpsIn.filters = new List <object>() { filter }; secOpsIn.allowed_operations = new List <string>() { "read" }; Assert.DoesNotThrow(() => { var scopedKey = ScopedKey.Encrypt(settings.MasterKey, (object)secOpsIn, IV); var decrypted = ScopedKey.Decrypt(settings.MasterKey, scopedKey); var secOpsOut = JObject.Parse(decrypted); Assert.True(secOpsIn.allowed_operations[0] == (string)(secOpsOut["allowed_operations"].First())); }); }
public void Encrypt_PopulatedObject_Success() { Assert.DoesNotThrow(() => { var settings = new ProjectSettingsProviderEnv(); const string str = "{\"filters\": [{\"property_name\": \"account_id\",\"operator\": \"eq\",\"property_value\": 123}],\"allowed_operations\": [ \"read\" ]}"; var secOps = JObject.Parse(str); var scopedKey = ScopedKey.Encrypt(settings.MasterKey, secOps); }); }
public void RoundTrip_PopulatedObject_WithIV_Success() { var settings = new ProjectSettingsProviderEnv(); const string IV = "C0FFEEC0FFEEC0FFEEC0FFEEC0FFEEC0"; const string str = "{\"filters\": [{\"property_name\": \"account_id\",\"operator\": \"eq\",\"property_value\": 123}],\"allowed_operations\": [ \"read\" ]}"; var secOps = JObject.Parse(str); Assert.DoesNotThrow(() => { var scopedKey = ScopedKey.Encrypt(settings.MasterKey, secOps, IV); var decrypted = ScopedKey.Decrypt(settings.MasterKey, scopedKey); var secOpsOut = JObject.Parse(decrypted); Assert.True((string)secOps["allowed_operations"].First() == (string)(secOpsOut["allowed_operations"].First())); }); }
public void Encrypt_PopulatedObject_Success() { Assert.DoesNotThrow(() => { var settings = new ProjectSettingsProviderEnv(); dynamic secOps = new ExpandoObject(); IDictionary <string, object> filter = new ExpandoObject(); filter.Add("property_name", "account_id"); filter.Add("operator", "eq"); filter.Add("property_value", 123); secOps.filters = new List <object>() { filter }; secOps.allowed_operations = new List <string>() { "read" }; var scopedKey = ScopedKey.Encrypt(settings.MasterKey, (object)secOps); }); }
public void Encrypt_NullKey_Throws() { Assert.Throws <Keen.Core.KeenException>(() => ScopedKey.Encrypt(null, new { X = "X" })); }
public void Encrypt_NullObject_Success() { Assert.DoesNotThrow(() => ScopedKey.Encrypt("0123456789ABCDEF0123456789ABCDEF", null)); }
public void Encrypt_64CharKey_Success() { Assert.DoesNotThrow(() => ScopedKey.Encrypt("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", null)); }
public void Encrypt_BlankKey_Success() { Assert.DoesNotThrow(() => ScopedKey.Encrypt("", new { X = "X" })); }
public void Encrypt_NullKey_Success() { Assert.DoesNotThrow(() => ScopedKey.Encrypt(null, new { X = "X" })); }
public void Encrypt_NullObject_Success() { Assert.DoesNotThrow(() => ScopedKey.Encrypt("abc", null)); }
public void Encrypt_BlankKey_Throws() { Assert.Throws <KeenException>(() => ScopedKey.Encrypt("", new { X = "X" })); }