From 19fb8fcf7cc957b34034b658ee1a0f34ac9d0d73 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 11 Aug 2016 18:21:01 -0400 Subject: [PATCH] Add a test for unicode tags to ensure they cannot be set Fixes #1324 --- test/test_api_usage.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/test_api_usage.py b/test/test_api_usage.py index 5c629b5ac..a415594eb 100644 --- a/test/test_api_usage.py +++ b/test/test_api_usage.py @@ -2333,6 +2333,29 @@ class TestRevertTag(ApiTestCase): class TestListAndDeleteTag(ApiTestCase): + def test_invalid_tags(self): + self.login(ADMIN_ACCESS_USER) + + # List the images for staging. + json = self.getJsonResponse(RepositoryTagImages, + params=dict(repository=ADMIN_ACCESS_USER + '/complex', + tag='staging')) + + staging_images = json['images'] + + # Try to add some invalid tags. + self.putResponse(RepositoryTag, + params=dict(repository=ADMIN_ACCESS_USER + '/complex', tag='-fail'), + data=dict(image=staging_images[0]['id']), + expected_code=400) + + self.putResponse(RepositoryTag, + params=dict(repository=ADMIN_ACCESS_USER + '/complex', tag='北京'), + data=dict(image=staging_images[0]['id']), + expected_code=400) + + + def test_listdeletecreateandmovetag(self): self.login(ADMIN_ACCESS_USER)