Open techcobweb opened 1 month ago
From @eamansour 👍🏻
Looks good, I just changed the DELETE endpoint’s response code to 204 (no content) instead of a 200 - also noticed the story mentions using --login_id
in the users commands, shouldn’t that be --id
? (since that’s what we have already for users get --id
me)
Story
As a user of a galasa ecosystem, I want to see a list of other users using the command line. So that I can see who uses this system.
Background
We need to create a User record in couchdb whenever we discover a user in the system.
Neither of these cases is performance-sensitive, so we can spare the time to look the user up in the couchdb database, and create a record if one doesn't already exist.
This is a pre-req for having a role associated with each user.
Couchdb database layer
We need to create it if it doesn't already exist, when the API starts up.
Couchdb records look like this:
Document 6789087678988678798
:Currently we aim to capture only the last login from either interface. Later on we might capture the last 5, or the last 5 months' activity...etc.
Servlet layer
The existing web service should gather the list and return it using the endpoint we have already. ie:
/api/users
That should return a list of all the users we know about in couchdb.
ie:
GET https://myhost/api/users
: returns:We also need an endpoint specifically for one user: eg:
GET https://myhost/api/users/6789087678988678798
:Because the rest API is being used to obtain JWTs, the rest API is aware of whether it's the web UI asking for the JWT, or whether it's a REST client program asking for it. As the REST API has access to the users extension API, and indirectly to couchdb, then there should be no need for a PUT REST command yet for the user resource.
We also need to be able to delete a user record:
DELETE https://myhost/api/users/6789087678988678798
Return code: 204Note that the REST interface deals with users based on their document ID, while the CLI deals with users based on their login ID (as that's more friendly to users). By doing this we byepass any problems with code pages, or users with weird characters in their names.
Given that the user login-id is supplied by git/ldap...etc we can't second-guess the validation rules for a login-id.
Without the DELETE, we will struggle to test this feature.
The CLI layer
The CLI should be able to query the list of users:
It should support --format of type summary/details.
It should default to summary.
It should have a Title line and a total at the bottom.
For example:
or
The user can specify a filter for users:
When a filtered option is used, using the
--login-id
field, then the default should be thedetails
view.The user can be deleted:
(There is no visible response, beyond a '0' exit code to indicate success).
The Web UI layer
The user's last-login information is visible on the user profile page.
Tasks
CLI tasks
delete
Servlet layer tasks
[ ] The servlet endpoint supports querying using the
?login-id=xxxx
query parameter for real.[ ] The servlet endpoint allows the GET of a single user
[x] The servlet endpoint allows the PUT of a single user
[ ] Support DELETE of a single user
[ ] When a user is deleted, all their access tokens are removed
[x] The user record is created in couchdb when the user first logs on, if not already known about.
[ ] The user record is created in couchdb when the user uses their GALASA_TOKEN to get a JWT
[ ] The last-logged-in field is retained and updated whenever a JWT is obtained.
[ ] The last-logged-in field is visible in the CLI
Couchdb tasks
Web UI tasks