public void data_generatorConstructorTest_smoke_test() { IDataRepository db = new Database_mock_up(_sample_remote_pub_key, _sample_remote_shared_key); int key = 1234567; data_generator target = new data_generator(db, key); Assert.IsNotNull(target.LoginData); }
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_expire_session_during_login_attempt() { Database_mock_up db = new Database_mock_up(_sample_remote_pub_key, _sample_remote_shared_key); AuthenticationController_Accessor target = new AuthenticationController_Accessor(db); int id = db.sessionID; string data = validate_key.dirty_key(encrypt_message(db.get_session(id), make_Hashkey_to_string(db.calculatedKey))); Assert.IsFalse(((Database_mock_up)((AuthenticationController_Accessor)target)._db).is_session_expired(id)); ViewResult actual = target.authenticate(data, db.sessionID) as ViewResult; Assert.IsTrue(((Database_mock_up)((AuthenticationController_Accessor)target)._db).is_session_expired(id)); }
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 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)); }