Browse Source

Merge "Double quote www_authenticate_uri"

Zuul 1 year ago
parent
commit
686f7a5b0b

+ 1
- 1
keystonemiddleware/auth_token/__init__.py View File

@@ -679,7 +679,7 @@ class AuthProtocol(BaseAuthProtocol):
679 679
 
680 680
     @property
681 681
     def _reject_auth_headers(self):
682
-        header_val = 'Keystone uri=\'%s\'' % self._www_authenticate_uri
682
+        header_val = 'Keystone uri="%s"' % self._www_authenticate_uri
683 683
         return [('WWW-Authenticate', header_val)]
684 684
 
685 685
     def _token_hashes(self, token):

+ 9
- 9
keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py View File

@@ -956,37 +956,37 @@ class CommonAuthTokenMiddlewareTest(object):
956 956
 
957 957
         resp = self.call_middleware(headers={'X-Auth-Token': 'invalid-token'},
958 958
                                     expected_status=401)
959
-        self.assertEqual("Keystone uri='https://keystone.example.com:1234'",
959
+        self.assertEqual('Keystone uri="https://keystone.example.com:1234"',
960 960
                          resp.headers['WWW-Authenticate'])
961 961
 
962 962
     def test_request_invalid_signed_token(self):
963 963
         token = self.examples.INVALID_SIGNED_TOKEN
964 964
         resp = self.call_middleware(headers={'X-Auth-Token': token},
965 965
                                     expected_status=401)
966
-        self.assertEqual("Keystone uri='https://keystone.example.com:1234'",
966
+        self.assertEqual('Keystone uri="https://keystone.example.com:1234"',
967 967
                          resp.headers['WWW-Authenticate'])
968 968
 
969 969
     def test_request_invalid_signed_pkiz_token(self):
970 970
         token = self.examples.INVALID_SIGNED_PKIZ_TOKEN
971 971
         resp = self.call_middleware(headers={'X-Auth-Token': token},
972 972
                                     expected_status=401)
973
-        self.assertEqual("Keystone uri='https://keystone.example.com:1234'",
973
+        self.assertEqual('Keystone uri="https://keystone.example.com:1234"',
974 974
                          resp.headers['WWW-Authenticate'])
975 975
 
976 976
     def test_request_no_token(self):
977 977
         resp = self.call_middleware(expected_status=401)
978
-        self.assertEqual("Keystone uri='https://keystone.example.com:1234'",
978
+        self.assertEqual('Keystone uri="https://keystone.example.com:1234"',
979 979
                          resp.headers['WWW-Authenticate'])
980 980
 
981 981
     def test_request_no_token_http(self):
982 982
         resp = self.call_middleware(method='HEAD', expected_status=401)
983
-        self.assertEqual("Keystone uri='https://keystone.example.com:1234'",
983
+        self.assertEqual('Keystone uri="https://keystone.example.com:1234"',
984 984
                          resp.headers['WWW-Authenticate'])
985 985
 
986 986
     def test_request_blank_token(self):
987 987
         resp = self.call_middleware(headers={'X-Auth-Token': ''},
988 988
                                     expected_status=401)
989
-        self.assertEqual("Keystone uri='https://keystone.example.com:1234'",
989
+        self.assertEqual('Keystone uri="https://keystone.example.com:1234"',
990 990
                          resp.headers['WWW-Authenticate'])
991 991
 
992 992
     def _get_cached_token(self, token, mode='md5'):
@@ -1126,7 +1126,7 @@ class CommonAuthTokenMiddlewareTest(object):
1126 1126
             self.assert_valid_last_url(token)
1127 1127
         else:
1128 1128
             self.assertEqual(401, resp.status_int)
1129
-            msg = "Keystone uri='https://keystone.example.com:1234'"
1129
+            msg = 'Keystone uri="https://keystone.example.com:1234"'
1130 1130
             self.assertEqual(msg, resp.headers['WWW-Authenticate'])
1131 1131
 
1132 1132
     def test_uuid_bind_token_disabled_with_kerb_user(self):
@@ -1660,7 +1660,7 @@ class v2AuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest,
1660 1660
         """Unscoped requests with no default tenant ID should be rejected."""
1661 1661
         resp = self.call_middleware(headers={'X-Auth-Token': token},
1662 1662
                                     expected_status=401)
1663
-        self.assertEqual("Keystone uri='https://keystone.example.com:1234'",
1663
+        self.assertEqual('Keystone uri="https://keystone.example.com:1234"',
1664 1664
                          resp.headers['WWW-Authenticate'])
1665 1665
 
1666 1666
     def test_unscoped_uuid_token_receives_401(self):
@@ -2030,7 +2030,7 @@ class DelayedAuthTests(BaseAuthTokenMiddlewareTest):
2030 2030
         resp = self.call(middleware, expected_status=401)
2031 2031
         self.assertEqual(six.b(body), resp.body)
2032 2032
 
2033
-        self.assertEqual("Keystone uri='%s'" % www_authenticate_uri,
2033
+        self.assertEqual('Keystone uri="%s"' % www_authenticate_uri,
2034 2034
                          resp.headers['WWW-Authenticate'])
2035 2035
 
2036 2036
     def test_delayed_auth_values(self):

+ 6
- 0
releasenotes/notes/bug-1762362-3d092b15c7bab3a4.yaml View File

@@ -0,0 +1,6 @@
1
+---
2
+features:
3
+  - >
4
+    [`bug 1762362 <https://bugs.launchpad.net/keystonemiddleware/+bug/1762362>`_]
5
+    The value of the header "WWW-Authenticate" in a 401 (Unauthorized) response
6
+    now is double quoted to follow the RFC requirement.

Loading…
Cancel
Save