@@ -51,22 +51,48 @@ def test_default_public_false(source_api_server, path, method, token_builder):
51
51
52
52
53
53
@pytest .mark .parametrize (
54
- "token,permitted" ,
54
+ "rules, token,permitted" ,
55
55
[
56
- [{"scope" : "collection:create" }, True ],
57
- [{"scope" : "" }, False ],
58
- [{"scope" : "openid" }, False ],
59
- [{"scope" : "openid collection:create" }, True ],
56
+ [
57
+ [("POST" , "collection:create" )],
58
+ {"scope" : "collection:create" },
59
+ True ,
60
+ ],
61
+ [
62
+ [("POST" , "collection:create" )],
63
+ {"scope" : "" },
64
+ False ,
65
+ ],
66
+ [
67
+ [("POST" , "collection:create" )],
68
+ {"scope" : "openid" },
69
+ False ,
70
+ ],
71
+ [
72
+ [("POST" , "collection:create" )],
73
+ {"scope" : "openid collection:create" },
74
+ True ,
75
+ ],
76
+ [
77
+ [("POST" , "foo collection:create" )],
78
+ {"scope" : "openid collection:create foo" },
79
+ True ,
80
+ ],
81
+ [
82
+ [("GET" , "collection:read" ), ("POST" , "collection:create" )],
83
+ {"scope" : "openid collection:read" },
84
+ False ,
85
+ ],
60
86
],
61
87
)
62
88
def test_default_public_false_with_scopes (
63
- source_api_server , token , permitted , token_builder
89
+ source_api_server , rules , token , permitted , token_builder
64
90
):
65
91
"""Private endpoints permit access with a valid token."""
66
92
test_app = app_factory (
67
93
upstream_url = source_api_server ,
68
94
default_public = False ,
69
- private_endpoints = {r"^/collections$" : [( "POST" , [ "collection:create" ])] },
95
+ private_endpoints = {r"^/collections$" : rules },
70
96
)
71
97
valid_auth_token = token_builder (token )
72
98
@@ -84,31 +110,31 @@ def test_default_public_false_with_scopes(
84
110
[
85
111
pytest .param (
86
112
"" ,
87
- {r"^/*" : [("POST" , [ "collection:create" ] )]},
113
+ {r"^/*" : [("POST" , "collection:create" )]},
88
114
"/collections" ,
89
115
"POST" ,
90
116
False ,
91
117
id = "empty scopes + private endpoint" ,
92
118
),
93
119
pytest .param (
94
120
"openid profile collection:createbutnotcreate" ,
95
- {r"^/*" : [("POST" , [ "collection:create" ] )]},
121
+ {r"^/*" : [("POST" , "collection:create" )]},
96
122
"/collections" ,
97
123
"POST" ,
98
124
False ,
99
125
id = "invalid scopes + private endpoint" ,
100
126
),
101
127
pytest .param (
102
128
"openid profile collection:create somethingelse" ,
103
- {r"^/*" : [("POST" , [] )]},
129
+ {r"^/*" : [("POST" , "" )]},
104
130
"/collections" ,
105
131
"POST" ,
106
132
True ,
107
133
id = "valid scopes + private endpoint without required scopes" ,
108
134
),
109
135
pytest .param (
110
136
"openid" ,
111
- {r"^/collections/.*/items$" : [("POST" , [ "collection:create" ] )]},
137
+ {r"^/collections/.*/items$" : [("POST" , "collection:create" )]},
112
138
"/collections" ,
113
139
"GET" ,
114
140
True ,
0 commit comments