public void BuildListOfAccessibleVaults_returns_vaults() { var accountInfo = JObject.Parse(JsonHttpClientTest.ReadFixture("account-info")); var vaults = Client.BuildListOfAccessibleVaults(accountInfo); Assert.That(vaults, Is.EquivalentTo(new[] { "ru74fjxlkipzzctorwj4icrj2a", "4tz67op2kfiapodi5ygprtwn64" })); }
public void SignOut_throws_on_bad_response() { var http = MakeJsonHttp(JsonHttpClientTest.SetupPut("{'success': 0}")); Assert.That(() => Client.SignOut(http), ExceptionsTest.ThrowsRespondedWithErrorWithMessage("Failed to sign out")); }
public void DecryptKeys_stores_keys_in_keychain() { var accountInfo = JObject.Parse(JsonHttpClientTest.ReadFixture("account-info")); var keysets = JObject.Parse(JsonHttpClientTest.ReadFixture("keysets")); var keychain = new Keychain(); Client.DecryptAllKeys(accountInfo, keysets, ClientInfo, keychain); var aesKeys = new[] { "mp", "x4ouqoqyhcnqojrgubso4hsdga", "byq5gi5adlasqyy2l2o7iddzvq", }; foreach (var i in aesKeys) { Assert.That(keychain.GetAes(i), Is.Not.Null); } var keysetIds = new[] { "szerdhg2ww2ahjo4ilz57x7cce", "yf2ji37vkqdow7pnbo3y37b3lu", "srkx3r5c3qgyzsdswfc4awgh2m", "sm5hkw3mxwdcwcgljf4kyplwea", }; foreach (var i in keysetIds) { Assert.That(keychain.GetAes(i), Is.Not.Null); Assert.That(keychain.GetRsa(i), Is.Not.Null); } }
public void GetAccountInfo_makes_GET_request_to_specific_url() { var http = MakeJsonHttp(JsonHttpClientTest.SetupGetWithFixture("get-account-info-response")); Client.GetAccountInfo(TestData.SesionKey, http); JsonHttpClientTest.VerifyGetUrl(http.Http, "1password.com/api/v1/account"); }
public void GetKeysets_makes_GET_request_to_specific_url() { var http = MakeJsonHttp(JsonHttpClientTest.SetupGetWithFixture("empty-object-response")); Client.GetKeysets(TestData.SesionKey, http); JsonHttpClientTest.VerifyGetUrl(http.Http, "1password.com/api/v1/account/keysets"); }
public void SignOut_makes_PUT_request_to_specific_url() { var http = MakeJsonHttp(JsonHttpClientTest.SetupPut("{'success': 1}")); Client.SignOut(http); JsonHttpClientTest.VerifyPutUrl(http.Http, "1password.com/api/v1/session/signout"); }
public void ExchangeAForB_makes_POST_request_to_specific_url() { var http = SetupJsonHttp("exchange-a-for-b-response"); Srp.ExchangeAForB(0, TestData.MakeSession(), http); JsonHttpClientTest.VerifyPostUrl(http, "1password.com/api/v1/auth"); }
public void RegisterDevice_throws_on_error() { var http = MakeJsonHttp(JsonHttpClientTest.SetupPost("{'success': 0}")); Assert.That(() => Client.RegisterDevice(TestData.ClientInfo, http), ExceptionsTest.ThrowsRespondedWithErrorWithMessage(TestData.Uuid) .And.Message.StartsWith("Failed to register")); }
public void StartNewSession_makes_GET_request_to_specific_url() { var http = MakeJsonHttp(JsonHttpClientTest.SetupGetWithFixture("start-new-session-response")); Client.StartNewSession(TestData.ClientInfo, http); JsonHttpClientTest.VerifyGetUrl(http.Http, "1password.com/api/v2/auth"); }
public void RegisterDevice_makes_POST_request_to_specific_url() { var http = MakeJsonHttp(JsonHttpClientTest.SetupPost("{'success': 1}")); Client.RegisterDevice(TestData.ClientInfo, http); JsonHttpClientTest.VerifyPostUrl(http.Http, "1password.com/api/v1/device"); }
public void StartNewSession_throws_on_unknown_status() { var http = MakeJsonHttp(JsonHttpClientTest.SetupGet("{'status': 'unknown'}")); Assert.That(() => Client.StartNewSession(TestData.ClientInfo, http), ExceptionsTest.ThrowsInvalidResponseWithMessage("'unknown'") .And.Message.StartsWith("Failed to start a new session")); }
public void VerifySessionKey_makes_POST_request_to_specific_url() { var http = MakeJsonHttp(JsonHttpClientTest.SetupPostWithFixture("verify-key-response")); Client.VerifySessionKey(TestData.ClientInfo, TestData.Session, TestData.SesionKey, http); JsonHttpClientTest.VerifyPostUrl(http.Http, "1password.com/api/v2/auth/verify"); }
public void StartNewSession_throws_on_invalid_json() { var jsonHttp = new JsonHttpClient( JsonHttpClientTest.SetupGet("} invalid json {").Object, ""); Assert.That(() => Client.StartNewSession(TestData.ClientInfo, jsonHttp), ExceptionsTest.ThrowsInvalidResponseWithMessage("Invalid JSON")); }
public void StartNewSession_throws_on_network_error() { var jsonHttp = new JsonHttpClient(JsonHttpClientTest.SetupGetWithFailure().Object, ""); Assert.That(() => Client.StartNewSession(TestData.ClientInfo, jsonHttp), ExceptionsTest.ThrowsReasonWithMessage( ClientException.FailureReason.NetworkError, "request")); }
public void GetVaultAccounts_with_no_items_work() { var http = MakeJsonHttp(JsonHttpClientTest.SetupGetWithFixture("get-vault-with-no-items-response")); var keychain = new Keychain(); keychain.Add(new AesKey("x4ouqoqyhcnqojrgubso4hsdga", "ce92c6d1af345c645211ad49692b22338d128d974e3b6718c868e02776c873a9".DecodeHex())); Client.GetVaultAccounts("ru74fjxlkipzzctorwj4icrj2a", TestData.SesionKey, keychain, http); }
public void StartNewSession_returns_session_on_ok() { var http = MakeJsonHttp(JsonHttpClientTest.SetupGetWithFixture("start-new-session-response")); var session = Client.StartNewSession(TestData.ClientInfo, http); Assert.That(session.Id, Is.EqualTo(TestData.Session.Id)); Assert.That(session.KeyFormat, Is.EqualTo(TestData.Session.KeyFormat)); Assert.That(session.KeyUuid, Is.EqualTo(TestData.Session.KeyUuid)); Assert.That(session.SrpMethod, Is.EqualTo(TestData.Session.SrpMethod)); Assert.That(session.KeyMethod, Is.EqualTo(TestData.Session.KeyMethod)); Assert.That(session.Iterations, Is.EqualTo(TestData.Session.Iterations)); Assert.That(session.Salt, Is.EqualTo(TestData.Session.Salt)); }
public void GetVaultAccounts_makes_GET_request_to_specific_url() { var http = MakeJsonHttp( JsonHttpClientTest.SetupGetWithFixture("get-vault-accounts-ru74-response")); var keychain = new Keychain(); keychain.Add(new AesKey("x4ouqoqyhcnqojrgubso4hsdga", "ce92c6d1af345c645211ad49692b22338d128d974e3b6718c868e02776c873a9".DecodeHex())); Client.GetVaultAccounts("ru74fjxlkipzzctorwj4icrj2a", TestData.SesionKey, keychain, http); JsonHttpClientTest.VerifyGetUrl(http.Http, "1password.com/api/v1/vault"); }
public void VerifySessionKey_works() { var http = MakeJsonHttp(JsonHttpClientTest.SetupPostWithFixture("verify-key-response")); Client.VerifySessionKey(TestData.ClientInfo, TestData.Session, TestData.SesionKey, http); }
private static JsonHttpClient SetupJsonHttp(string fixture) { return(new JsonHttpClient(JsonHttpClientTest.SetupPostWithFixture(fixture).Object, Client.GetApiUrl(Client.DefaultDomain))); }
public void RegisterDevice_works() { var http = MakeJsonHttp(JsonHttpClientTest.SetupPost("{'success': 1}")); Client.RegisterDevice(TestData.ClientInfo, http); }
public void GetAccountInfo_works() { var http = MakeJsonHttp(JsonHttpClientTest.SetupGetWithFixture("get-account-info-response")); Client.GetAccountInfo(TestData.SesionKey, http); }
public void GetKeysets_works() { var http = MakeJsonHttp(JsonHttpClientTest.SetupGetWithFixture("empty-object-response")); Client.GetKeysets(TestData.SesionKey, http); }
public void SignOut_works() { var http = MakeJsonHttp(JsonHttpClientTest.SetupPut("{'success': 1}")); Client.SignOut(http); }