public void authenticateTest_should_fail_login_when_given_bad_session_id() { Database_mock_up db = new Database_mock_up(_sample_remote_pub_key, _sample_remote_shared_key); AuthenticationController target = new AuthenticationController(db); string data = validate_key.dirty_key(make_Hashkey_to_string(db.calculatedKey)); int id = 111111; ViewResult actual = target.authenticate(data, id) as ViewResult; Assert.AreEqual(_bad_login_message, actual.ViewBag.message); }
public void authenticateTest_should_fail_login_when_given_incorrect_login_data() { Database_mock_up db = new Database_mock_up(_sample_remote_pub_key,_sample_remote_shared_key); AuthenticationController target = new AuthenticationController(db); db.calculatedKey = seedHashWithBadValues(db.calculatedKey); int id = db.sessionID; string data = validate_key.dirty_key(encrypt_message(db.get_session(id), make_Hashkey_to_string(db.calculatedKey))); ViewResult actual = target.authenticate(data, id) as ViewResult; Assert.AreEqual(_bad_login_message, actual.ViewBag.message); }
public void authenticateTest_should_gracefully_handle_a_bad_message_after_decryption() { Database_mock_up db = new Database_mock_up(_sample_remote_pub_key, _sample_remote_shared_key); AuthenticationController target = new AuthenticationController(db); int id = db.sessionID; string data = validate_key.dirty_key(encrypt_message(db.get_session(id), "junk")); ViewResult actual = target.authenticate(data, id) as ViewResult; Assert.AreNotEqual(_good_login_message, actual.ViewBag.message); }
public void initializeTest_when_given_string_in_pubKey_should_return_fake_data() { AuthenticationController target = new AuthenticationController(new Database_mock_up(_sample_remote_pub_key, _sample_remote_shared_key)); long shared_key = 4325465423452345; ViewResult actual = target.initialize(_sample_remote_pub_key, Convert.ToString(shared_key)) as ViewResult; Assert.IsNotNull(actual.ViewBag.message); Assert.AreEqual("lasdflj2fjlwjefljawlj3", actual.ViewBag.message); }
public void initializeTest_when_given_good_key_should_return_real_data() { AuthenticationController target = new AuthenticationController(new Database_mock_up(_sample_remote_pub_key, _sample_remote_shared_key)); string remote_public_key = Convert.ToString(_sample_pub_key); // includes key checking items long shared_key = _sample_remote_shared_key; ViewResult actual = target.initialize(Int64.Parse(remote_public_key), validate_key.dirty_key(Convert.ToString( shared_key))) as ViewResult; Assert.IsNotNull(actual.ViewBag.message); Assert.AreNotEqual("lasdflj2fjlwjefljawlj3", actual.ViewBag.message); }
public void initializeTest_when_given_bad_key_should_return_fake_data() { AuthenticationController target = new AuthenticationController(new Database_mock_up(_sample_remote_pub_key, _sample_remote_shared_key)); string remote_public_key = "43335359345345345"; // does not include key checking items long shared_key = 4325465423452345; ViewResult actual = target.initialize(Int64.Parse(remote_public_key), Convert.ToString(shared_key)) as ViewResult; Assert.IsNotNull(actual.ViewBag.message); Assert.AreEqual("lasdflj2fjlwjefljawlj3", actual.ViewBag.message); }
public void authenticateTest_should_launch_nuke_when_given_proper_login_data() { Database_mock_up db = new Database_mock_up(_sample_remote_pub_key, _sample_remote_shared_key); AuthenticationController target = new AuthenticationController(db); int id = db.sessionID; string data = validate_key.dirty_key(encrypt_message(db.get_session(id), make_Hashkey_to_string(db.calculatedKey))); ViewResult actual = target.authenticate(data,id) as ViewResult; Assert.AreEqual(_good_login_message, decrypt_message(db.get_session(id),actual.ViewBag.message)); }