4 Commits

Author SHA1 Message Date
Philip Meulengracht
13a1c0ca10 multiple: add a spread test for the auto-removal of expired system-users. Make use of --force when removing users due to expiration, otherwise it is possible to block the removal the user if the user left a process open. 2022-10-31 14:05:48 +01:00
Philip Meulengracht
24437a0c4a daemon: support for expiration date in REST API 2022-10-20 12:14:40 +02:00
Ondrej
a044081e73 daemon: move user add, remove operations to overlord device state (#11796)
* daemon,o/devicestate: move user creation and removal helpers to o/devicestate

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* daemon,o/devicestate: move user create,remove tests to o/devicestate

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* daemon: add new tests for user create,remove requests

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* o/devicestate: removed unused variable in users test

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* o/devicestate: move users test export to common export

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* o/devicestate: remove left behind commented code

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* o/devicestate: clean syntax in user helper

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* daemon: use testutil.Backup() in api export tests

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* o/devicestate: use testutil.Backup() in api export tests

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* daemon: cleanup user tests

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* overlord/devicestate: join helper variables for mocking

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* overlord/devicestate: remove extra line in addUser function

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* overlord/devicestat: rename internal_err -> internalErr

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* overlord/devicestate: change addUser fnc signature

addUser adds single user. Change function signarure to return single UserResponse
Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* overlord/devicestate: update error handling in CreateUser

Update error handling after merge from master

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* overlord/devicestate: remove accidental file from merge conflict

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* daemon,overlord: user error wrapper for user account actions

CreateUser, RemoveUser can fail for multiple reasons.
There is a need to distinguish between internal error and bad request.
Use UserError structure to wrap/ return error information.

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* daemon,overlord: address review issues

- renaming UserResponse to CreatedUser
- fix typos
- fix error wrapping
- rename ue to error
- code cleanup

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* overlord/devicestate: rework createUserOpts helper for user creation

- remove unused and confusing safe flag for create user operations
- remove state from struct and pass it as function argument

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* overlord/devicestate: add test for missing email in user creation

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* daemon,overlord: split CreateUser function for known and unknown users

Split CreateUser functionality into two new functions
- CreateKnownUsers for creation of known users
- CreateUser for creation of user defined by email

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* overlord: use new auth.NewUserData structure

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* overlord/devicestate,daemon: review feedback

Reorder functions, drop wrapping internal errors, assume state lock on function entry to match the style in managers

* daemon,overlord/devicestate: review feedback

add missing unit test, remove devicemanager parameter, fix doc string

* daemon: review feedback

simplify some else conditions, rename function and variable

* overlord/devicestate: review feedback

move createUser down to the structure it belongs to

* daemon: review feedback + changes to how we return users

simplify a lot of the methods, change to pointer instead so we can return nil's instead of empty structures. Remove the option structure for creating new users, update some docs

* daemon: review feedback

rename doUserWrapper/doCreateUser

* daemon: restore tests, restore the backwards compatible way of creating users

* daemon,overlord: review feedback

rewrite testPostCreateUserFromAssertion, it was no longer valid after code seperation, instead focus on testing the code in api_users.go
update checks in users_test.go, one was invalid (overwritten), rest was missing verification of calling

* daemon,overlord/devicestate: review feedback

redo some of the error messages, move the logic check for creating known users in compat-mode, update comments a bit

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
Co-authored-by: Philip Meulengracht <the_meulengracht@hotmail.com>
2022-09-30 09:33:37 +02:00
Samuele Pedroni
59cad6bc49 daemon: move api_users_test.go to daemon_test
export some bits of APIBaseSuite for this (at least for now)

move a couple of tests back to api_test.go temporarely
2020-11-20 20:51:29 +01:00