@@ -2,8 +2,7 @@ mod common;
22
33use rocket:: http:: { Accept , ContentType , Status } ;
44
5- use zauth:: models:: client:: { Client , NewClient } ;
6- use zauth:: models:: role:: { NewRole , Role } ;
5+ use zauth:: models:: role:: { NewRole , Role , RoleVisibility } ;
76use zauth:: models:: user:: User ;
87
98use crate :: common:: HttpClient ;
@@ -51,8 +50,9 @@ async fn create_role_as_user() {
5150async fn create_global_role ( ) {
5251 common:: as_admin ( async move |http_client : HttpClient , db, _user| {
5352 let role_name = "test" ;
54- let role_form =
55- format ! ( "name={role_name}&description=test_description" ) ;
53+ let role_form = format ! (
54+ "name={role_name}&description=test_description&visibility=global"
55+ ) ;
5656
5757 let response = http_client
5858 . post ( "/roles" )
@@ -70,27 +70,17 @@ async fn create_global_role() {
7070
7171 assert_eq ! ( created. name, role_name) ;
7272 assert_eq ! ( created. description, "test_description" ) ;
73- assert_eq ! ( created. client_id , None ) ;
73+ assert_eq ! ( created. visibility , RoleVisibility :: Global ) ;
7474 } )
7575 . await ;
7676}
7777
7878#[ rocket:: async_test]
79- async fn create_client_role ( ) {
79+ async fn create_limited_role ( ) {
8080 common:: as_admin ( async move |http_client : HttpClient , db, _user| {
81- let client = Client :: create (
82- NewClient {
83- name : String :: from ( "test" ) ,
84- } ,
85- & db,
86- )
87- . await
88- . unwrap ( ) ;
89-
9081 let role_name = "test" ;
9182 let role_form = format ! (
92- "name={role_name}&description=test_description&client_id={}" ,
93- client. id
83+ "name={role_name}&description=test_description&visibility=limited" ,
9484 ) ;
9585
9686 let response = http_client
@@ -109,7 +99,7 @@ async fn create_client_role() {
10999
110100 assert_eq ! ( created. name, role_name) ;
111101 assert_eq ! ( created. description, "test_description" ) ;
112- assert_eq ! ( created. client_id , Some ( client . id ) ) ;
102+ assert_eq ! ( created. visibility , RoleVisibility :: Limited ) ;
113103 } )
114104 . await ;
115105}
@@ -121,7 +111,7 @@ async fn show_role_as_user() {
121111 NewRole {
122112 name : "test" . into ( ) ,
123113 description : "test" . into ( ) ,
124- client_id : None ,
114+ visibility : RoleVisibility :: Global ,
125115 } ,
126116 & db,
127117 )
@@ -145,7 +135,7 @@ async fn show_role_as_admin() {
145135 NewRole {
146136 name : "test" . into ( ) ,
147137 description : "test" . into ( ) ,
148- client_id : None ,
138+ visibility : RoleVisibility :: Global ,
149139 } ,
150140 & db,
151141 )
@@ -168,7 +158,7 @@ async fn delete_role() {
168158 NewRole {
169159 name : "test" . into ( ) ,
170160 description : "test" . into ( ) ,
171- client_id : None ,
161+ visibility : RoleVisibility :: Global ,
172162 } ,
173163 & db,
174164 )
@@ -194,7 +184,7 @@ async fn add_user_to_role_as_user() {
194184 NewRole {
195185 name : "test" . into ( ) ,
196186 description : "test" . into ( ) ,
197- client_id : None ,
187+ visibility : RoleVisibility :: Global ,
198188 } ,
199189 & db,
200190 )
@@ -223,7 +213,7 @@ async fn add_user_to_role_as_admin() {
223213 NewRole {
224214 name : "test" . into ( ) ,
225215 description : "test" . into ( ) ,
226- client_id : None ,
216+ visibility : RoleVisibility :: Global ,
227217 } ,
228218 & db,
229219 )
@@ -264,7 +254,7 @@ async fn add_role_to_user_as_user() {
264254 NewRole {
265255 name : "test" . into ( ) ,
266256 description : "test" . into ( ) ,
267- client_id : None ,
257+ visibility : RoleVisibility :: Global ,
268258 } ,
269259 & db,
270260 )
@@ -293,7 +283,7 @@ async fn add_role_to_user_as_admin() {
293283 NewRole {
294284 name : "test" . into ( ) ,
295285 description : "test" . into ( ) ,
296- client_id : None ,
286+ visibility : RoleVisibility :: Global ,
297287 } ,
298288 & db,
299289 )
0 commit comments