1212import json
1313import threading
1414import time
15+ import urllib
1516import uuid
1617from typing import Dict , Optional
1718from unittest import mock
@@ -105,6 +106,13 @@ def test_request_headers(mock_get_and_post):
105106 headers = {
106107 accept_encoding_header : accept_encoding_value ,
107108 client_info_header : client_info_value ,
109+ },
110+ roles = {
111+ "hive" : "ALL" ,
112+ "system" : "analyst" ,
113+ "catalog1" : "NONE" ,
114+ # ensure backwards compatibility
115+ "catalog2" : "ROLE{catalog2_role}" ,
108116 }
109117 ),
110118 http_scheme = "http" ,
@@ -121,7 +129,13 @@ def assert_headers(headers):
121129 assert headers [constants .HEADER_CLIENT_CAPABILITIES ] == "PARAMETRIC_DATETIME"
122130 assert headers [accept_encoding_header ] == accept_encoding_value
123131 assert headers [client_info_header ] == client_info_value
124- assert len (headers .keys ()) == 10
132+ assert headers [constants .HEADER_ROLE ] == (
133+ "hive=ALL,"
134+ "system=" + urllib .parse .quote ("ROLE{analyst}" ) + ","
135+ "catalog1=NONE,"
136+ "catalog2=" + urllib .parse .quote ("ROLE{catalog2_role}" )
137+ )
138+ assert len (headers .keys ()) == 11
125139
126140 req .post ("URL" )
127141 _ , post_kwargs = post .call_args
@@ -1095,14 +1109,15 @@ def test_request_headers_role_admin(mock_get_and_post):
10951109 roles = {"system" : "admin" }
10961110 ),
10971111 )
1112+ roles = "system=" + urllib .parse .quote ("ROLE{admin}" )
10981113
10991114 req .post ("URL" )
11001115 _ , post_kwargs = post .call_args
1101- assert_headers_with_roles (post_kwargs ["headers" ], "system=admin" )
1116+ assert_headers_with_roles (post_kwargs ["headers" ], roles )
11021117
11031118 req .get ("URL" )
11041119 _ , get_kwargs = get .call_args
1105- assert_headers_with_roles (post_kwargs ["headers" ], "system=admin" )
1120+ assert_headers_with_roles (post_kwargs ["headers" ], roles )
11061121
11071122
11081123def test_request_headers_role_empty (mock_get_and_post ):
0 commit comments