Done
Details
Details
Assignee
Adam Cigánek
Adam CigánekReporter
Spandan Sharma
Spandan SharmaLabels
Start date
Dec 19, 2016
End date
Jan 02, 2017
Story Points
12
Components
Priority
Created December 19, 2016 at 2:12 PM
Updated September 11, 2018 at 9:03 AM
Resolved January 2, 2017 at 1:11 PM
Code the following tests for safe_authenticator in apporpriate modules:
1) Create random account (i.e. create authenticator) - should be successful. Login using same credentials - successful. Check user-root dir for entries related to all the standard dirs as mentioned in safe_core::nfs::mod.rs - successful. From MDataInfo for each obtained from user-root, get all permissions and entry-keys for each of those MData - successful. Assert they are blank - successful.
2) Create random account (i.e. create authenticator) - should be successful. Login using same credentials - successful. Check config-root dir for entries related to entry-key "authenticator-config" and "access-container" (should be encrypted using MDataInfo of config-root-dir) - successful. The entry-value for authenticator-config should be empty and corresponding to "access-container" should contain the MDataInfo of access-container - successful. List all entry keys and permissions for access-container and assert there are none - successful.
3) Create random authenticator - should be successful. Login using same credentials - successful. Create IpcMsg::AuthReq for a random App (random id, name, vendor etc), ask for app_container and containers "documents with permission to insert", "images with all the permissions possible", serialise it as base64 payload in "safe_authayload" - successful, invoke Authenticator's decode ipc msg and expect to get C-AuthReq back via callback - successful. Call the encode-auth-req with is_granted = true and assert a non-null FFI-string which mentions "safe_<app-id-as-base64>ayload" - successful. Convert payload to vec<u8> from base64 and deserialise into AuthGranted msg finally - successful. From Auth-granted check for access-container and using it check if there is an entry-key corresponding to this App and get the entry-value and check if "<app-id>", "documents" and "images" directories's MDataInfo is mentioned and using that get the permissions for images and documents and assert the permissions asked for is mentioned for the App-sign_pk got via AuthGranted, permission for dir name "app-id" should have all the permissions - successful. Check authenticator has put the app's info in config-root/authenticator-config and also in MaidManagers (get auth-keys should return the app's sign_pk in the list). Check user-root has an entry key "apps/<app-id>" with MDataInfo == MDataInfo obtained from access-container above.
4) Create random authenticator - should be successful. Login using same credentials - successful. Create IpcMsg::AuthReq for a random App (random id, name, vendor etc), ask for app_container and containers "documents with permission to insert", "images with all the permissions possible", serialise it as base64 payload in "safe_authayload" - successful, invoke Authenticator's decode ipc msg and expect to get C-AuthReq back via callback - successful. Call the encode-auth-req with is_granted = true and assert a non-null FFI-string which mentions "safe_<app-id-as-base64>ayload" - successful. Now give one more AuthReq to authenticator for the same app - the call back should be invoked with an error, error-code (i32) being AlreadyAuthorised - successful. Check the FfiString to contain "safe_<app-id-base64>ayload" where payload is IpcMsg::Resp(IpcResp::Auth(Err(AlreadyAuthorised)))" - successful.
Mention the above descriptions as comments on top of each test case above.