feat: Create admin protected endpoint for creating users#981
feat: Create admin protected endpoint for creating users#981jescalada merged 9 commits intofinos:mainfrom
Conversation
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
|
You could replace or remove this test, which is currently skipped, with your new tests: git-proxy/test/testUserCreation.test.js Lines 42 to 50 in 3718943 |
d6f580d to
271916f
Compare
jescalada
left a comment
There was a problem hiding this comment.
The code looks good! I've had some problems executing the tests, although some issues were present before.
Let me know if I'm missing something! 🙂
|
Also, it would be very helpful to execute the |
|
What's the status of this PR? @jescalada @dcoric |
I’m currently OOO but I plan to polish this up by the end of the week. I will ping here once it is ready for another review |
3f7a0be to
a4d3526
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #981 +/- ##
==========================================
+ Coverage 82.78% 82.86% +0.07%
==========================================
Files 66 66
Lines 2783 2795 +12
Branches 332 332
==========================================
+ Hits 2304 2316 +12
Misses 431 431
Partials 48 48 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@JamieSlome @jescalada I've implemented all the requested changes. I ran into some challenges with the tests, but everything should be working correctly now. When you have a moment, could you please review the updates? It should be all set for merging. Let me know if you spot anything else that needs adjustment - otherwise, it's good to go! |
a4d3526 to
d4d9020
Compare
jescalada
left a comment
There was a problem hiding this comment.
Looks good so far 👍🏼 I spent some time finding fixes for the failing CLI tests. Hopefully committing those directly will fix things.
- Add proper test setup/teardown for create-user tests - Fix missing required fields test to use empty password instead of omitting it - Use unique usernames with timestamps to prevent conflicts between test runs - Add proper cleanup for created users in finally blocks - Ensure all 42 CLI tests now pass consistently
jescalada
left a comment
There was a problem hiding this comment.
LGTM after fixing a flaky test!
We should probably merge this in first, and then the CLI TS refactor PR. I don't think it'll be too hard to add these changes to the PR 🤔
Fixes flaky test due to duplicate emails Co-authored-by: Juan Escalada <97265671+jescalada@users.noreply.github.com> Signed-off-by: Denis Ćorić <denis85@gmail.com>
Fixes flaky test due to duplicate email Co-authored-by: Juan Escalada <97265671+jescalada@users.noreply.github.com> Signed-off-by: Denis Ćorić <denis85@gmail.com>
Adds an error log in case of failed DB cleanup Co-authored-by: Juan Escalada <97265671+jescalada@users.noreply.github.com> Signed-off-by: Denis Ćorić <denis85@gmail.com>
Introduce a new API endpoint for creating users and a corresponding command in the git-proxy-cli to interact with this endpoint. The new functionality enables administrators to create new user accounts via the CLI.
Changes
createUserfunction topackages/git-proxy-cli/index.jsthat handles user creation via an API call. It checks for authentication cookies and makes a POST request to the/api/auth/create-userendpoint.create-usercommand to the CLI using yargs inpackages/git-proxy-cli/index.js. This command takes username, password, email, gitAccount, and an optional admin flag as arguments./api/auth/create-userinsrc/service/routes/auth.jsthat handles the user creation request. It checks for admin privileges and validates the request body before creating the user in the database.packages/git-proxy-cli/test/testCli.test.js, covering scenarios such as server down, no authentication, missing required fields and successful user creation./api/auth/create-userroute totest/testLogin.test.jsto verify authentication, authorization, data validation, and successful user creation.Impact
create-usercommand to thegit-proxy-cli, enabling administrators to create user accounts directly from the command line./api/auth/create-userendpoint is now available, allowing authenticated administrators to create new user accounts.axioslibrary inpackages/git-proxy-cli/index.js.src/service/routes/auth.jsto create user records.Resolves #980