def test_api_key_rejects_update_of_nonexistent_key(self):
stderr = StringIO()
user = factory.make_User()
fake_api_key_name = "Test Key Name"
existing_token = get_one(
user.userprofile.get_authorisation_tokens())
token_string = convert_tuple_to_string(
get_creds_tuple(existing_token))
call_command(
'apikey', username=user.username, delete=token_string,
stderr=stderr)
self.assertThat(stderr, IsEmpty)
# Try to update the deleted token.
error_text = assertCommandErrors(
self, 'apikey', username=user.username, update=token_string,
api_key_name=fake_api_key_name)
self.assertIn(
"No matching api key found", error_text)
评论列表
文章目录