def test_unpair(self): """ QRToken unittest: checking if unpairing works """ fake = FakeTokenModel() token = QrTokenClass(fake) token.addToTokenInfo('user_token_id', 'bar') token.addToTokenInfo('user_public_key', 'foo') token.change_state('baz') token.unpair() self.assertNotIn('user_token_id', fake.info_dict) self.assertNotIn('user_public_key', fake.info_dict) self.assertEqual('pairing_url_sent', token.current_state)
def test_unpair(self): """QRToken unittest: checking if unpairing works""" fake = FakeTokenModel() token = QrTokenClass(fake) token.addToTokenInfo("user_token_id", "bar") token.addToTokenInfo("user_public_key", "foo") token.change_state("baz") token.unpair() assert "user_token_id" not in fake.info_dict assert "user_public_key" not in fake.info_dict assert "pairing_url_sent" == token.current_state
def test_url_protocol_id(self, mocked_get_secret_key): """ QRToken unittest: Test url protocol id customization """ mocked_get_secret_key.return_value = 'X' * 64 user_public_key = 'MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=' fake = FakeTokenModel() token = QrTokenClass(fake) token.addToTokenInfo('user_token_id', 1234) token.addToTokenInfo('user_public_key', user_public_key) with nested(patch.dict(config), request_context_safety()): if 'mobile_app_protocol_id' in config: del config['mobile_app_protocol_id'] request_context['hsm'] = fake_hsm_wrapper # if no mobile_app_protocol_id is set, it should default # to lseqr message = 'here are the 2,750 quit you asked for. can i move' + \ 'to OT I level now? - tom' url, _ = token.create_challenge_url(transaction_id='1234567890', content_type=0, message=message, callback_url='foo', callback_sms_number='+491234') self.assertTrue(url.startswith('lseqr://')) # -------------------------------------------------------------------- - fake = FakeTokenModel() token = QrTokenClass(fake) token.addToTokenInfo('user_token_id', 1234) token.addToTokenInfo('user_public_key', user_public_key) with nested(patch.dict(config, {'mobile_app_protocol_id': 'yolo'}), request_context_safety()): request_context['hsm'] = fake_hsm_wrapper message = 'here are the 2,750 quit you asked for. can i move' + \ 'to OT I level now? - tom' url, _ = token.create_challenge_url(transaction_id='1234567890', content_type=0, message=message, callback_url='foo', callback_sms_number='+491234') self.assertTrue(url.startswith('yolo://'))
def test_url_protocol_id(self, base_app, mocked_get_secret_key): """ QRToken unittest: Test url protocol id customization """ mocked_get_secret_key.return_value = "X" * 64 user_public_key = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=" fake = FakeTokenModel() token = QrTokenClass(fake) token.addToTokenInfo("user_token_id", 1234) token.addToTokenInfo("user_public_key", user_public_key) with base_app.test_request_context(): if "mobile_app_protocol_id" in config: del config["mobile_app_protocol_id"] request_context["hsm"] = fake_hsm_wrapper # if no mobile_app_protocol_id is set, it should default # to lseqr message = ("here are the 2,750 quit you asked for. can i move" + "to OT I level now? - tom") url, _ = token.create_challenge_url( transaction_id="1234567890", content_type=0, message=message, callback_url="foo", callback_sms_number="+491234", ) assert url.startswith("lseqr://") # -------------------------------------------------------------------- - fake = FakeTokenModel() token = QrTokenClass(fake) token.addToTokenInfo("user_token_id", 1234) token.addToTokenInfo("user_public_key", user_public_key) with base_app.test_request_context(): config["mobile_app_protocol_id"] = "yolo" request_context["hsm"] = fake_hsm_wrapper message = ("here are the 2,750 quit you asked for. can i move" + "to OT I level now? - tom") url, _ = token.create_challenge_url( transaction_id="1234567890", content_type=0, message=message, callback_url="foo", callback_sms_number="+491234", ) assert url.startswith("yolo://")