Changing default policy

This commit is contained in:
Tomasz Drwięga
2016-12-11 17:51:34 +01:00
parent 4696d7f606
commit 627b8a8414
3 changed files with 13 additions and 5 deletions

View File

@@ -418,6 +418,8 @@ mod tests {
// given
let ap = AccountProvider::transient_provider();
let app = "app1".to_owned();
// set `AllAccounts` policy
ap.set_new_dapps_whitelist(None).unwrap();
// when
ap.set_dapps_addresses(app.clone(), vec![1.into(), 2.into()]).unwrap();
@@ -431,10 +433,15 @@ mod tests {
// given
let ap = AccountProvider::transient_provider();
let address = ap.new_account("test").unwrap();
// Default policy should be to return all
// Default policy should be to return nothing
assert_eq!(ap.dapps_addresses("app1".into()).unwrap(), vec![]);
// change to all
ap.set_new_dapps_whitelist(None).unwrap();
assert_eq!(ap.dapps_addresses("app1".into()).unwrap(), vec![address]);
// change policy
// change to a whitelist
ap.set_new_dapps_whitelist(Some(vec![1.into()])).unwrap();
assert_eq!(ap.dapps_addresses("app1".into()).unwrap(), vec![1.into()]);
}

View File

@@ -175,7 +175,7 @@ impl DappsSettingsStore {
/// Returns current new dapps policy
pub fn policy(&self) -> NewDappsPolicy {
self.policy.get("default").cloned().unwrap_or(NewDappsPolicy::AllAccounts)
self.policy.get("default").cloned().unwrap_or(NewDappsPolicy::Whitelist(vec![]))
}
/// Returns recent dapps (in order of last request)
@@ -354,7 +354,7 @@ mod tests {
let path = temp.as_str().to_owned();
let mut store = DappsSettingsStore::new(path.clone());
// Test default policy
assert_eq!(store.policy(), NewDappsPolicy::AllAccounts);
assert_eq!(store.policy(), NewDappsPolicy::Whitelist(vec![]));
// when
store.set_policy(NewDappsPolicy::Whitelist(vec![1.into(), 2.into()]));