public void GetBlob_throws_on_not_HTTP_OK() { var http = SetupGet(HttpStatusCode.NotFound, new byte[0]); Assert.That(() => Client.GetBlob(TestData.Username, Session, http.Object), ExceptionsTest.ThrowsNetworkErrorWithMessage("NotFound (404)")); }
public void Step1_throws_on_missing_WWW_Authenticate_header() { var http = SetupStep1(null); Assert.That( () => Client.Step1(TestData.Credentials, new Client.OtpOptions(), http.Object), ExceptionsTest.ThrowsInvalidResponseWithMessage("WWW-Authenticate header")); }
public void Step2_throws_http_unauthorized() { var http = SetupStep2(HttpStatusCode.Unauthorized); Assert.That(() => Client.Step2(TestData.Credentials, new Client.OtpOptions(), TestData.AuthInfo, http.Object), ExceptionsTest.ThrowsIncorrectCredentialsWithMessage("Username or password")); }
public void Decrypt_throws_on_invalid_iteration_count() { var iterations = new[] { new byte[] { 0, 0, 0, 0 }, new byte[] { 0, 0x08, 0, 1 } }; foreach (var i in iterations) { Assert.That(DecryptPad("gsencst1\x00\x02".ToBytes().Concat(i).ToArray()), ExceptionsTest.ThrowsParseErrorWithMessage("iteration count")); } }
public void Parse_throws_on_invalid_content_length() { var lengths = new[] { new byte[] { 0, 0, 0, 0x80 }, new byte[] { 0xFF, 0xFF, 0xFF, 0xFF } }; foreach (var i in lengths) { Assert.That(ParsePad("onefile1\x07\x01".ToBytes().Concat(i).ToArray()), ExceptionsTest.ThrowsParseErrorWithMessage("negative")); } }
public void Step2_throws_on_missing_cookies() { var testCases = new[] { new string[] {}, new[] { "sib-auth=auth" }, new[] { "sib-deviceid=deviceid" }, new[] { "blah=blah-blah" }, new[] { "sib-auth=auth", "blah=blah-blah" }, }; foreach (var testCase in testCases) { var http = SetupStep2(testCase); Assert.That(() => Client.Step2(TestData.Credentials, new Client.OtpOptions(), TestData.AuthInfo, http.Object), ExceptionsTest.ThrowsInvalidResponseWithMessage("cookie")); } }
public void Logout_throws_on_not_HTTP_OK() { Assert.That(() => Logout(HttpStatusCode.NotFound), ExceptionsTest.ThrowsNetworkErrorWithMessage("NotFound (404)")); }
public void Decrypt_throws_on_unsupported_invalid_kdf() { Assert.That(DecryptPad("gsencst1\x00" + "\x05"), ExceptionsTest.ThrowsParseErrorWithMessage("KDF/encryption type")); }
public void Decrypt_throws_on_unsupported_sha1_kdf() { Assert.That(DecryptPad("gsencst1\x00" + "\x01"), ExceptionsTest.ThrowsUnsupportedFeatureWithMessage("SHA-1")); }
public void Decrypt_throws_on_invalid_signature() { Assert.That(DecryptPad("invalid!"), ExceptionsTest.ThrowsParseErrorWithMessage("signature")); }
public void Parse_throws_on_too_short_content() { Assert.That(ParsePad("onefile1\x07\x01\x02\x00\x00\x00" + "invalid checksum" + "!"), ExceptionsTest.ThrowsParseErrorWithMessage("too short")); }
public void Parse_throws_on_invalid_checksum() { Assert.That(ParsePad("onefile1\x07\x01\x01\x00\x00\x00" + "invalid checksum" + "!"), ExceptionsTest.ThrowsParseErrorWithMessage("Checksum")); }
public void Parse_throws_on_invalid_checksum_type() { Assert.That(ParsePad("onefile1\x07" + "\x13"), ExceptionsTest.ThrowsParseErrorWithMessage("checksum")); }
public void Parse_throws_unencrypted_content() { Assert.That(ParsePad("onefile1" + "\x05"), ExceptionsTest.ThrowsUnsupportedFeatureWithMessage("Unencrypted")); }
public void ParseJson_throws_on_invalid_json() { Assert.That(() => OneFile.ParseJson("}{".ToBytes()), ExceptionsTest.ThrowsParseErrorWithMessage("Corrupted")); }
public void Decrypt_throws_on_too_short_extra() { Assert.That(DecryptPad("gsencst1\x10\x02\x00\x10\x00\x00\x10saltsaltsaltsalt" + "extra..."), ExceptionsTest.ThrowsParseErrorWithMessage("too short")); }
public void Decrypt_throws_on_no_content() { Assert.That(Decrypt("too short".ToBytes()), ExceptionsTest.ThrowsParseErrorWithMessage("too short")); }
// // Helpers // private static void VerifyThrows(Action action) { Assert.That(new TestDelegate(action), ExceptionsTest.ThrowsInvalidResponseWithMessage("Invalid auth info")); }