@@ -6,11 +6,19 @@ use crate::{
66} ;
77use backend_api:: {
88 ApiError , ApiResult , CreateMyUserProfileResponse , GetMyUserProfileHistoryResponse ,
9- GetMyUserProfileResponse , UpdateMyUserProfileRequest , UpdateUserProfileRequest ,
9+ GetMyUserProfileResponse , ListReviewerProfilesResponse , UpdateMyUserProfileRequest ,
10+ UpdateUserProfileRequest ,
1011} ;
1112use candid:: Principal ;
1213use ic_cdk:: * ;
1314
15+ #[ query]
16+ fn list_reviewer_profiles ( ) -> ApiResult < ListReviewerProfilesResponse > {
17+ UserProfileController :: default ( )
18+ . list_reviewer_profiles ( )
19+ . into ( )
20+ }
21+
1422#[ query]
1523fn get_my_user_profile ( ) -> ApiResult < GetMyUserProfileResponse > {
1624 let calling_principal = caller ( ) ;
@@ -84,6 +92,12 @@ impl<A: AccessControlService, U: UserProfileService> UserProfileController<A, U>
8492 }
8593 }
8694
95+ fn list_reviewer_profiles ( & self ) -> Result < ListReviewerProfilesResponse , ApiError > {
96+ let profiles = self . user_profile_service . list_reviewer_profiles ( ) ?;
97+
98+ Ok ( profiles)
99+ }
100+
87101 fn get_my_user_profile (
88102 & self ,
89103 calling_principal : Principal ,
@@ -163,16 +177,39 @@ mod tests {
163177 use super :: * ;
164178 use crate :: {
165179 fixtures,
166- mappings:: { map_get_my_user_profile_history_response, map_get_my_user_profile_response} ,
180+ mappings:: {
181+ map_get_my_user_profile_history_response, map_get_my_user_profile_response,
182+ map_list_reviewer_profiles_response,
183+ } ,
167184 services:: { MockAccessControlService , MockUserProfileService } ,
168185 } ;
169186 use backend_api:: UserConfig ;
170187 use mockall:: predicate:: * ;
171188 use rstest:: * ;
172189
190+ #[ rstest]
191+ fn list_reviewer_profiles ( ) {
192+ let profiles = map_list_reviewer_profiles_response ( vec ! [ (
193+ fixtures:: user_id( ) ,
194+ fixtures:: reviewer_user_profile( ) ,
195+ ) ] ) ;
196+
197+ let mut service_mock = MockUserProfileService :: new ( ) ;
198+ service_mock
199+ . expect_list_reviewer_profiles ( )
200+ . once ( )
201+ . return_const ( Ok ( profiles. clone ( ) ) ) ;
202+
203+ let controller = UserProfileController :: new ( MockAccessControlService :: new ( ) , service_mock) ;
204+
205+ let result = controller. list_reviewer_profiles ( ) . unwrap ( ) ;
206+
207+ assert_eq ! ( result, profiles) ;
208+ }
209+
173210 #[ rstest]
174211 fn get_my_user_profile ( ) {
175- let calling_principal = fixtures:: principal ( ) ;
212+ let calling_principal = fixtures:: principal_a ( ) ;
176213 let profile =
177214 map_get_my_user_profile_response ( fixtures:: user_id ( ) , fixtures:: admin_user_profile ( ) ) ;
178215
@@ -224,7 +261,7 @@ mod tests {
224261
225262 #[ rstest]
226263 fn get_my_user_profile_no_profile ( ) {
227- let calling_principal = fixtures:: principal ( ) ;
264+ let calling_principal = fixtures:: principal_a ( ) ;
228265 let error = ApiError :: not_found ( "User profile not found" ) ;
229266
230267 let mut access_control_service_mock = MockAccessControlService :: new ( ) ;
@@ -253,7 +290,7 @@ mod tests {
253290
254291 #[ rstest]
255292 fn get_my_user_profile_history ( ) {
256- let calling_principal = fixtures:: principal ( ) ;
293+ let calling_principal = fixtures:: principal_a ( ) ;
257294 let profile_history =
258295 map_get_my_user_profile_history_response ( fixtures:: user_profile_history ( ) ) ;
259296
@@ -329,7 +366,7 @@ mod tests {
329366
330367 #[ rstest]
331368 async fn create_my_user_profile ( ) {
332- let calling_principal = fixtures:: principal ( ) ;
369+ let calling_principal = fixtures:: principal_a ( ) ;
333370 let profile = CreateMyUserProfileResponse {
334371 id : "id" . to_string ( ) ,
335372 username : "username" . to_string ( ) ,
@@ -387,7 +424,7 @@ mod tests {
387424
388425 #[ rstest]
389426 fn update_user_profile ( ) {
390- let calling_principal = fixtures:: principal ( ) ;
427+ let calling_principal = fixtures:: principal_a ( ) ;
391428 let user_id = fixtures:: user_id ( ) ;
392429 let request = UpdateUserProfileRequest {
393430 user_id : user_id. to_string ( ) ,
@@ -423,7 +460,7 @@ mod tests {
423460
424461 #[ rstest]
425462 fn update_my_user_profile ( ) {
426- let calling_principal = fixtures:: principal ( ) ;
463+ let calling_principal = fixtures:: principal_a ( ) ;
427464 let request = UpdateMyUserProfileRequest {
428465 username : Some ( "username" . to_string ( ) ) ,
429466 config : None ,
@@ -511,7 +548,7 @@ mod tests {
511548
512549 #[ rstest]
513550 fn update_user_profile_non_admin_principal ( ) {
514- let calling_principal = fixtures:: principal ( ) ;
551+ let calling_principal = fixtures:: principal_a ( ) ;
515552 let user_id = fixtures:: user_id ( ) ;
516553 let request = UpdateUserProfileRequest {
517554 user_id : user_id. to_string ( ) ,
0 commit comments