@@ -132,3 +132,33 @@ def test_apply_role_assignment(admin_api_client, rando, inv_rd, inventory):
132132 # Second try, response code indicates assignment already exists
133133 response = admin_api_client .post (url , data = data )
134134 assert response .status_code == 409 , response .data
135+
136+
137+ @pytest .mark .django_db
138+ def test_filter_assignment_list (admin_api_client , rando , inv_rd , view_inv_rd , org_inv_rd , inventory ):
139+ inv_rd .give_permission (rando , inventory )
140+ org_inv_rd .give_permission (rando , inventory .organization )
141+ view_inv_rd .give_permission (rando , inventory )
142+
143+ url = get_relative_url ('serviceuserassignment-list' )
144+ response = admin_api_client .get (url + f'?user={ rando .id } ' , format = "json" )
145+ assert response .status_code == 200 , response .data
146+ assert response .data ['count' ] == 3 # user rando has 3 rol assignments
147+
148+ # Get just one single assignment
149+ response = admin_api_client .get (url + f'?assignment={ str (rando .resource .ansible_id )} ,{ inv_rd .name } ,{ inventory .id } ' , format = "json" )
150+ assert response .status_code == 200 , response .data
151+ assert response .data ['count' ] == 1
152+ assert response .data ['results' ][0 ]['role_definition' ] == inv_rd .name
153+
154+ # Assure we can get two assignments at the same time
155+ response = admin_api_client .get (
156+ url
157+ + (
158+ f'?assignment={ str (rando .resource .ansible_id )} ,{ inv_rd .name } ,{ inventory .id } &'
159+ f'assignment={ str (rando .resource .ansible_id )} ,{ org_inv_rd .name } ,{ inventory .organization .id } '
160+ ),
161+ format = "json" ,
162+ )
163+ assert response .status_code == 200 , response .data
164+ assert response .data ['count' ] == 2
0 commit comments