1515async  def  test_opa_graphql_decision_auto_error ():
1616    oauth2lib_settings .OAUTH2_ACTIVE  =  False 
1717    authorization  =  GraphQLOPAAuthorization (opa_url = "https://opa_url.test" )
18-     assert  await  authorization .authorize ("" , cast (OIDCUserModel , {})) is  None 
18+     assert  await  authorization .authorize ("" , "QUERY" ,  cast (OIDCUserModel , {})) is  None 
1919    oauth2lib_settings .OAUTH2_ACTIVE  =  True 
2020
2121
@@ -28,13 +28,13 @@ async def test_opa_graphql_decision_user_not_allowed_autoerror_true(make_mock_as
2828    with  patch ("oauth2_lib.fastapi.AsyncClient" , return_value = mock_async_client ):
2929        authorization  =  GraphQLOPAAuthorization (opa_url = "https://opa_url.test" , auto_error = True )
3030        with  pytest .raises (HTTPException ) as  exception_info :
31-             await  authorization .authorize ("/test/path" , user_info = user_info_matching )
31+             await  authorization .authorize ("/test/path" , "QUERY" ,  user_info = user_info_matching )
3232
3333        assert  exception_info .value .status_code  ==  HTTPStatus .FORBIDDEN 
3434        expected_detail  =  f"User is not allowed to access resource: /test/path Decision was taken with id: { '8ef9daf0-1a23-4a6b-8433-c64ef028bee8' }  
3535        assert  exception_info .value .detail  ==  expected_detail 
3636
37-         opa_input  =  {"input" : {** user_info_matching , "resource" : "/test/path" , "method" : "POST " }}
37+         opa_input  =  {"input" : {** user_info_matching , "resource" : "/test/path" , "method" : "QUERY " }}
3838        mock_async_client .client .post .assert_called_with ("https://opa_url.test" , json = opa_input )
3939
4040
@@ -46,14 +46,14 @@ async def test_opa_graphql_decision_user_not_allowed_autoerror_false(make_mock_a
4646
4747    with  patch ("oauth2_lib.fastapi.AsyncClient" , return_value = mock_async_client ):
4848        authorization  =  GraphQLOPAAuthorization (opa_url = "https://opa_url.test" , auto_error = False )
49-         result  =  await  authorization .authorize ("/test/path" , user_info_matching )
49+         result  =  await  authorization .authorize ("/test/path" , "QUERY" ,  user_info_matching )
5050
5151        assert  result  is  False 
5252        opa_input  =  {
5353            "input" : {
5454                ** user_info_matching ,
5555                "resource" : "/test/path" ,
56-                 "method" : "POST " ,
56+                 "method" : "QUERY " ,
5757            }
5858        }
5959        mock_async_client .client .post .assert_called_with ("https://opa_url.test" , json = opa_input )
@@ -67,14 +67,14 @@ async def test_opa_graphql_decision_user_allowed(make_mock_async_client):
6767
6868    with  patch ("oauth2_lib.fastapi.AsyncClient" , return_value = mock_async_client ):
6969        authorization  =  GraphQLOPAAuthorization (opa_url = "https://opa_url.test" , auto_error = False )
70-         result  =  await  authorization .authorize ("/test/path" , user_info_matching )
70+         result  =  await  authorization .authorize ("/test/path" , "QUERY" ,  user_info_matching )
7171
7272        assert  result  is  True 
7373        opa_input  =  {
7474            "input" : {
7575                ** user_info_matching ,
7676                "resource" : "/test/path" ,
77-                 "method" : "POST " ,
77+                 "method" : "QUERY " ,
7878            }
7979        }
8080        mock_async_client .client .post .assert_called_with ("https://opa_url.test" , json = opa_input )
@@ -88,7 +88,7 @@ async def test_opa_graphql_decision_network_or_type_error(make_mock_async_client
8888        authorization  =  GraphQLOPAAuthorization (opa_url = "https://opa_url.test" )
8989
9090        with  pytest .raises (HTTPException ) as  exception :
91-             await  authorization .authorize ("/test/path" , user_info_matching )
91+             await  authorization .authorize ("/test/path" , "QUERY" ,  user_info_matching )
9292
9393        assert  exception .value .status_code  ==  503 
9494        assert  exception .value .detail  ==  "Policy agent is unavailable" 
@@ -105,7 +105,7 @@ async def test_opa_graphql_decision_kwargs(make_mock_async_client):
105105            opa_url = "https://opa_url.test" , auto_error = False , opa_kwargs = {"extra" : 3 }
106106        )
107107
108-         result  =  await  authorization .authorize ("/test/path" , user_info_matching )
108+         result  =  await  authorization .authorize ("/test/path" , "QUERY" ,  user_info_matching )
109109
110110        assert  result  is  True 
111111
@@ -114,7 +114,7 @@ async def test_opa_graphql_decision_kwargs(make_mock_async_client):
114114                "extra" : 3 ,
115115                ** user_info_matching ,
116116                "resource" : "/test/path" ,
117-                 "method" : "POST " ,
117+                 "method" : "QUERY " ,
118118            }
119119        }
120120        mock_async_client .client .post .assert_called_with ("https://opa_url.test" , json = opa_input )
@@ -131,15 +131,15 @@ async def test_opa_decision_auto_error_not_allowed(make_mock_async_client):
131131            opa_url = "https://opa_url.test" , opa_kwargs = {"extra" : 3 }, auto_error = False 
132132        )
133133
134-         result  =  await  authorization .authorize ("/test/path" , user_info_matching )
134+         result  =  await  authorization .authorize ("/test/path" , "QUERY" ,  user_info_matching )
135135
136136        assert  result  is  False 
137137        opa_input  =  {
138138            "input" : {
139139                "extra" : 3 ,
140140                ** user_info_matching ,
141141                "resource" : "/test/path" ,
142-                 "method" : "POST " ,
142+                 "method" : "QUERY " ,
143143            }
144144        }
145145        mock_async_client .client .post .assert_called_with ("https://opa_url.test" , json = opa_input )
@@ -156,15 +156,15 @@ async def test_opa_graphql_decision_auto_error_allowed(make_mock_async_client):
156156            opa_url = "https://opa_url.test" , opa_kwargs = {"extra" : 3 }, auto_error = False 
157157        )
158158
159-         result  =  await  authorization .authorize ("/test/path" , user_info_matching )
159+         result  =  await  authorization .authorize ("/test/path" , "QUERY" ,  user_info_matching )
160160
161161        assert  result  is  True 
162162        opa_input  =  {
163163            "input" : {
164164                "extra" : 3 ,
165165                ** user_info_matching ,
166166                "resource" : "/test/path" ,
167-                 "method" : "POST " ,
167+                 "method" : "QUERY " ,
168168            }
169169        }
170170        mock_async_client .client .post .assert_called_with ("https://opa_url.test" , json = opa_input )
0 commit comments