Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
remove organization and build data from from GET /user
Browse files Browse the repository at this point in the history
  • Loading branch information
karenetheridge committed Nov 10, 2020
1 parent f1aa60d commit 7944847
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 27 deletions.
54 changes: 52 additions & 2 deletions docs/json-schema/response.json
Expand Up @@ -3018,9 +3018,59 @@
"type" : "array",
"uniqueItems" : true
},
"UsersDetailed" : {
"Users" : {
"items" : {
"$ref" : "#/definitions/UserDetailed"
"additionalProperties" : false,
"properties" : {
"created" : {
"format" : "date-time",
"type" : "string"
},
"email" : {
"$ref" : "common.json#/definitions/email_address"
},
"force_password_change" : {
"type" : "boolean"
},
"id" : {
"$ref" : "common.json#/definitions/uuid"
},
"is_admin" : {
"type" : "boolean"
},
"last_login" : {
"format" : "date-time",
"type" : [
"null",
"string"
]
},
"last_seen" : {
"format" : "date-time",
"type" : [
"null",
"string"
]
},
"name" : {
"type" : "string"
},
"refuse_session_auth" : {
"type" : "boolean"
}
},
"required" : [
"id",
"name",
"email",
"created",
"last_login",
"last_seen",
"refuse_session_auth",
"force_password_change",
"is_admin"
],
"type" : "object"
},
"type" : "array",
"uniqueItems" : true
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/Conch::Controller::User.md
Expand Up @@ -106,8 +106,8 @@ The response uses the UserError json schema for some error conditions; on succes

### get\_all

List all active users and their workspaces, builds and organizations. System admin only.
Response uses the UsersDetailed json schema.
List all active users. System admin only.
Response uses the Users json schema.

### create

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/Conch::Route::User.md
Expand Up @@ -171,7 +171,7 @@ Optionally accepts the following query parameters:

- Requires system admin authorization
- Controller/Action: ["get\_all" in Conch::Controller::User](../modules/Conch%3A%3AController%3A%3AUser#get_all)
- Response: [response.json#/definitions/UsersDetailed](../json-schema/response.json#/definitions/UsersDetailed)
- Response: [response.json#/definitions/Users](../json-schema/response.json#/definitions/Users)

### `POST /user?send_mail=<1|0>`

Expand Down
37 changes: 35 additions & 2 deletions json-schema/response.yaml
Expand Up @@ -1674,11 +1674,44 @@ definitions:
$ref: common.yaml#/definitions/role
role_via_organization_id:
$ref: common.yaml#/definitions/uuid
UsersDetailed:
Users:
type: array
uniqueItems: true
items:
$ref: '#/definitions/UserDetailed'
type: object
additionalProperties: false
required:
- id
- name
- email
- created
- last_login
- last_seen
- refuse_session_auth
- force_password_change
- is_admin
properties:
id:
$ref: common.yaml#/definitions/uuid
name:
type: string
email:
$ref: common.yaml#/definitions/email_address
created:
type: string
format: date-time
last_login:
type: [ 'null', string ]
format: date-time
last_seen:
type: [ 'null', string ]
format: date-time
refuse_session_auth:
type: boolean
force_password_change:
type: boolean
is_admin:
type: boolean
UserSettings:
type: object
propertyNames:
Expand Down
13 changes: 3 additions & 10 deletions lib/Conch/Controller/User.pm
Expand Up @@ -435,22 +435,15 @@ sub update ($c) {

=head2 get_all
List all active users and their workspaces, builds and organizations. System admin only.
Response uses the UsersDetailed json schema.
List all active users. System admin only.
Response uses the Users json schema.
=cut

sub get_all ($c) {
my $user_rs = $c->db_user_accounts
->active
->prefetch({
user_workspace_roles => 'workspace',
user_organization_roles => { organization => {
organization_build_roles => 'build',
} },
user_build_roles => 'build',
})
->order_by([ map $_.'.name', qw(user_account workspace organization build) ]);
->order_by('name');

return $c->status(200, [ $user_rs->all ]);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Conch/Route/User.pm
Expand Up @@ -427,7 +427,7 @@ Optionally accepts the following query parameters:
=item * Controller/Action: L<Conch::Controller::User/get_all>
=item * Response: F<response.yaml#/definitions/UsersDetailed>
=item * Response: F<response.yaml#/definitions/Users>
=back
Expand Down
18 changes: 9 additions & 9 deletions t/integration/users.t
Expand Up @@ -258,10 +258,10 @@ subtest 'User' => sub {

$t_super->get_ok('/user')
->status_is(200)
->json_schema_is('UsersDetailed')
->json_schema_is('Users')
->json_cmp_deeply([
(map +{
$_->%*,
$_->%{qw(id name email created refuse_session_auth force_password_change is_admin)},
last_login => re(qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,9}Z$/),
last_seen => re(qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,9}Z$/),
}, $super_user_data, $user_detailed),
Expand Down Expand Up @@ -712,14 +712,14 @@ subtest 'modify another user' => sub {

$t_super->get_ok('/user')
->status_is(200)
->json_schema_is('UsersDetailed')
->json_schema_is('Users')
->json_cmp_deeply([
(map +{
$_->%*,
last_login => re(qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,9}Z$/),
last_seen => re(qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,9}Z$/),
}, $super_user_data, $user_detailed),
$new_user_data,
(map +{
$_->%{qw(id name email created refuse_session_auth force_password_change is_admin)},
last_login => re(qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,9}Z$/),
last_seen => re(qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,9}Z$/),
}, $super_user_data, $user_detailed),
{ $new_user_data->%{qw(id name email created last_login last_seen refuse_session_auth force_password_change is_admin)} },
]);

$t_super->post_ok('/user?send_mail=0',
Expand Down

0 comments on commit 7944847

Please sign in to comment.