@@ -19,10 +19,7 @@ use sea_orm::{DbConn, entity::*};
1919use std:: sync:: Arc ;
2020
2121use openstack_keystone:: config:: Config ;
22- use openstack_keystone:: db:: entity:: {
23- assignment, group, prelude:: * , project, role, sea_orm_active_enums:: Type , user,
24- user_group_membership,
25- } ;
22+ use openstack_keystone:: db:: entity:: { prelude:: * , project} ;
2623use openstack_keystone:: keystone:: Service ;
2724use openstack_keystone:: plugin_manager:: PluginManager ;
2825use openstack_keystone:: policy:: PolicyFactory ;
@@ -69,157 +66,6 @@ async fn setup_assignment_data(db: &DbConn) -> Result<(), Report> {
6966 . exec ( db)
7067 . await ?;
7168
72- // Roles
73- Role :: insert_many ( [
74- role:: ActiveModel {
75- id : Set ( "role_ga" . into ( ) ) ,
76- name : Set ( "role_ga" . into ( ) ) ,
77- extra : NotSet ,
78- description : NotSet ,
79- domain_id : Set ( "domain_a" . to_string ( ) ) ,
80- } ,
81- role:: ActiveModel {
82- id : Set ( "role_gb" . into ( ) ) ,
83- name : Set ( "role_gb" . into ( ) ) ,
84- extra : NotSet ,
85- description : NotSet ,
86- domain_id : Set ( "domain_a" . to_string ( ) ) ,
87- } ,
88- role:: ActiveModel {
89- id : Set ( "role_c" . into ( ) ) ,
90- name : Set ( "role_c" . into ( ) ) ,
91- extra : NotSet ,
92- description : NotSet ,
93- domain_id : Set ( "domain_a" . to_string ( ) ) ,
94- } ,
95- role:: ActiveModel {
96- id : Set ( "role_gc" . into ( ) ) ,
97- name : Set ( "role_gc" . into ( ) ) ,
98- extra : NotSet ,
99- description : NotSet ,
100- domain_id : Set ( "domain_a" . to_string ( ) ) ,
101- } ,
102- role:: ActiveModel {
103- id : Set ( "role_d" . into ( ) ) ,
104- name : Set ( "role_d" . into ( ) ) ,
105- extra : NotSet ,
106- description : NotSet ,
107- domain_id : Set ( "domain_a" . to_string ( ) ) ,
108- } ,
109- role:: ActiveModel {
110- id : Set ( "role_gd" . into ( ) ) ,
111- name : Set ( "role_gd" . into ( ) ) ,
112- extra : NotSet ,
113- description : NotSet ,
114- domain_id : Set ( "domain_a" . to_string ( ) ) ,
115- } ,
116- ] )
117- . exec ( db)
118- . await ?;
119-
120- // Group
121- let group_a = group:: ActiveModel {
122- id : Set ( "group_a" . into ( ) ) ,
123- name : Set ( "group_a" . into ( ) ) ,
124- domain_id : Set ( "domain_a" . to_string ( ) ) ,
125- extra : NotSet ,
126- description : NotSet ,
127- }
128- . insert ( db)
129- . await ?;
130- // User
131- let user_a = user:: ActiveModel {
132- id : Set ( "user_a" . into ( ) ) ,
133- extra : NotSet ,
134- enabled : Set ( Some ( true ) ) ,
135- default_project_id : NotSet ,
136- last_active_at : NotSet ,
137- created_at : NotSet ,
138- domain_id : Set ( "domain_a" . to_string ( ) ) ,
139- }
140- . insert ( db)
141- . await ?;
142- user_group_membership:: ActiveModel {
143- user_id : Set ( user_a. id . clone ( ) ) ,
144- group_id : Set ( group_a. id . clone ( ) ) ,
145- }
146- . insert ( db)
147- . await ?;
148-
149- // Assignments
150- assignment:: ActiveModel {
151- r#type : Set ( Type :: UserDomain ) ,
152- actor_id : Set ( user_a. id . clone ( ) ) ,
153- target_id : Set ( "domain_a" . to_string ( ) ) ,
154- role_id : Set ( "role_a" . to_string ( ) ) ,
155- inherited : Set ( false ) ,
156- }
157- . insert ( db)
158- . await ?;
159- assignment:: ActiveModel {
160- r#type : Set ( Type :: GroupDomain ) ,
161- actor_id : Set ( group_a. id . clone ( ) ) ,
162- target_id : Set ( "domain_a" . to_string ( ) ) ,
163- role_id : Set ( "role_ga" . to_string ( ) ) ,
164- inherited : Set ( false ) ,
165- }
166- . insert ( db)
167- . await ?;
168- assignment:: ActiveModel {
169- r#type : Set ( Type :: UserDomain ) ,
170- actor_id : Set ( user_a. id . clone ( ) ) ,
171- target_id : Set ( "domain_a" . to_string ( ) ) ,
172- role_id : Set ( "role_b" . to_string ( ) ) ,
173- inherited : Set ( true ) ,
174- }
175- . insert ( db)
176- . await ?;
177- assignment:: ActiveModel {
178- r#type : Set ( Type :: GroupDomain ) ,
179- actor_id : Set ( group_a. id . clone ( ) ) ,
180- target_id : Set ( "domain_a" . to_string ( ) ) ,
181- role_id : Set ( "role_gb" . to_string ( ) ) ,
182- inherited : Set ( true ) ,
183- }
184- . insert ( db)
185- . await ?;
186- assignment:: ActiveModel {
187- r#type : Set ( Type :: UserProject ) ,
188- actor_id : Set ( user_a. id . clone ( ) ) ,
189- target_id : Set ( "project_a" . to_string ( ) ) ,
190- role_id : Set ( "role_c" . to_string ( ) ) ,
191- inherited : Set ( false ) ,
192- }
193- . insert ( db)
194- . await ?;
195- assignment:: ActiveModel {
196- r#type : Set ( Type :: GroupProject ) ,
197- actor_id : Set ( group_a. id . clone ( ) ) ,
198- target_id : Set ( "project_a" . to_string ( ) ) ,
199- role_id : Set ( "role_gc" . to_string ( ) ) ,
200- inherited : Set ( false ) ,
201- }
202- . insert ( db)
203- . await ?;
204- assignment:: ActiveModel {
205- r#type : Set ( Type :: UserProject ) ,
206- actor_id : Set ( user_a. id . clone ( ) ) ,
207- target_id : Set ( "project_a" . to_string ( ) ) ,
208- role_id : Set ( "role_d" . to_string ( ) ) ,
209- inherited : Set ( true ) ,
210- }
211- . insert ( db)
212- . await ?;
213- assignment:: ActiveModel {
214- r#type : Set ( Type :: GroupProject ) ,
215- actor_id : Set ( group_a. id . clone ( ) ) ,
216- target_id : Set ( "project_a" . to_string ( ) ) ,
217- role_id : Set ( "role_gd" . to_string ( ) ) ,
218- inherited : Set ( true ) ,
219- }
220- . insert ( db)
221- . await ?;
222-
22369 Ok ( ( ) )
22470}
22571
0 commit comments