diff --git a/docs/json-schema/response.json b/docs/json-schema/response.json index a33ed348a..0466f2e69 100644 --- a/docs/json-schema/response.json +++ b/docs/json-schema/response.json @@ -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 diff --git a/docs/modules/Conch::Controller::User.md b/docs/modules/Conch::Controller::User.md index e713ec255..e4898287a 100644 --- a/docs/modules/Conch::Controller::User.md +++ b/docs/modules/Conch::Controller::User.md @@ -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 diff --git a/docs/modules/Conch::Route::User.md b/docs/modules/Conch::Route::User.md index 7c37577bd..428f0ceeb 100644 --- a/docs/modules/Conch::Route::User.md +++ b/docs/modules/Conch::Route::User.md @@ -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>` diff --git a/json-schema/response.yaml b/json-schema/response.yaml index b4fb66d5b..088227c0d 100644 --- a/json-schema/response.yaml +++ b/json-schema/response.yaml @@ -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: diff --git a/lib/Conch/Controller/User.pm b/lib/Conch/Controller/User.pm index 8cdb4a618..855424121 100644 --- a/lib/Conch/Controller/User.pm +++ b/lib/Conch/Controller/User.pm @@ -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 ]); } diff --git a/lib/Conch/Route/User.pm b/lib/Conch/Route/User.pm index ed29e718b..7319d83d8 100644 --- a/lib/Conch/Route/User.pm +++ b/lib/Conch/Route/User.pm @@ -427,7 +427,7 @@ Optionally accepts the following query parameters: =item * Controller/Action: L -=item * Response: F +=item * Response: F =back diff --git a/t/integration/users.t b/t/integration/users.t index 790c6077a..64079cbdc 100644 --- a/t/integration/users.t +++ b/t/integration/users.t @@ -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), @@ -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',