@@ -72,34 +72,36 @@ def setUpClassApiKey(cls):
7272 def test_authenticated_auth_api_key_no_api_key (self ):
7373 # An exception is raised when no api key is used
7474 with self .assertRaises (HTTPException ) as error :
75- authenticated_auth_api_key (False , self .demo_env , self .demo_endpoint )
76- self .assertEqual (error .exception .detail , "Missing HTTP- API-KEY header" )
75+ authenticated_auth_api_key (self .demo_env , self .demo_endpoint )
76+ self .assertEqual (error .exception .detail , "Missing HTTP API key header" )
7777
7878 def test_authenticated_auth_api_key_no_api_key_found (self ):
79+ self .demo_endpoint .auth_http_api_key_header = "404"
7980 # An exception is raised when no api key record is found
8081 with self .assertRaises (HTTPException ) as error :
81- authenticated_auth_api_key ("404" , self .demo_env , self .demo_endpoint )
82+ authenticated_auth_api_key (self .demo_env , self .demo_endpoint )
8283 self .assertEqual (error .exception .detail , ("The key 404 is not allowed" ,))
8384
8485 def test_authenticated_auth_api_key_unauthorized_key (self ):
86+ self .demo_endpoint .auth_http_api_key_header = "unauthorized_key"
8587 # An exception is raised when unauthorized api key record is found
8688 with self .assertRaisesRegex (HTTPException , r"Unauthorized" ):
87- authenticated_auth_api_key (
88- "unauthorized_key" , self .demo_env , self .demo_endpoint
89- )
89+ authenticated_auth_api_key (self .demo_env , self .demo_endpoint )
9090
9191 def test_authenticated_auth_api_key (self ):
92- result_key = authenticated_auth_api_key (
93- "authorized_key" , self .demo_env , self .demo_endpoint
94- )
92+ self .demo_endpoint .auth_http_api_key_header = "authorized_key"
93+ result_key = authenticated_auth_api_key (self .demo_env , self .demo_endpoint )
9594 self .assertEqual (result_key , self .authorized_api_key )
9695
9796 def test_authenticated_auth_api_key_without_group (self ):
9897 # test with no group set unauthorized is allow to access
99- self .demo_endpoint .auth_api_key_group_id = False
100- result_key = authenticated_auth_api_key (
101- "unauthorized_key" , self .demo_env , self .demo_endpoint
98+ self .demo_endpoint .write (
99+ {
100+ "auth_api_key_group_id" : False ,
101+ "auth_http_api_key_header" : "unauthorized_key" ,
102+ }
102103 )
104+ result_key = authenticated_auth_api_key (self .demo_env , self .demo_endpoint )
103105 self .assertEqual (result_key , self .unauthorized_api_key )
104106
105107 def test_authenticated_partner_by_api_key (self ):
0 commit comments