Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secrets API #48

Merged
merged 15 commits into from
Feb 20, 2024
Merged

Secrets API #48

merged 15 commits into from
Feb 20, 2024

Conversation

dukris
Copy link
Collaborator

@dukris dukris commented Feb 16, 2024

@h1alexbel take a look, please
Closes #44


PR-Codex overview

This PR updates package names, adds secret-related functionality, and improves exception handling.

Detailed summary

  • Renamed packages from request to controller.request
  • Added Secret entity, controller, and SQL schema
  • Implemented RqSecret request record
  • Added ResourceAlreadyExistsException exception class

The following files were skipped due to too many changes: src/main/java/git/tracehub/pmo/secret/Secret.java, src/main/java/git/tracehub/pmo/controller/request/SecretFromReq.java, src/main/java/git/tracehub/pmo/secret/Secrets.java, src/main/java/git/tracehub/pmo/secret/SecretOf.java, src/main/java/git/tracehub/pmo/exception/Logged.java, src/main/java/git/tracehub/pmo/exception/RestError.java, src/test/java/git/tracehub/pmo/secret/MockSecret.java, src/test/java/git/tracehub/pmo/controller/request/SecretFromReqTest.java, src/test/java/git/tracehub/pmo/exception/RestErrorTest.java, src/main/java/git/tracehub/pmo/secret/UniqueSecrets.java, src/test/java/git/tracehub/pmo/exception/LoggedTest.java, src/test/java/git/tracehub/pmo/secret/SecretOfTest.java, src/main/java/git/tracehub/pmo/secret/DefaultSecrets.java, src/main/java/git/tracehub/pmo/controller/SecretController.java, src/test/java/it/database/DefaultSecretsIT.java, src/main/java/git/tracehub/pmo/controller/AdviceController.java, src/test/java/git/tracehub/pmo/secret/UniqueSecretsTest.java, src/test/java/it/web/RetrieveSecretByKeyITCase.java, src/test/java/git/tracehub/pmo/controller/SecretControllerTest.java, src/test/java/it/web/CreateSecretITCase.java, src/test/java/git/tracehub/pmo/secret/DefaultSecretsTest.java

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

codecov bot commented Feb 16, 2024

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (cc0964d) 79.18% compared to head (786aafb) 82.00%.

Files Patch % Lines
.../git/tracehub/pmo/controller/AdviceController.java 33.33% 12 Missing ⚠️
...n/java/git/tracehub/pmo/secret/DefaultSecrets.java 96.55% 1 Missing ⚠️
src/main/java/git/tracehub/pmo/secret/Secret.java 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #48      +/-   ##
============================================
+ Coverage     79.18%   82.00%   +2.81%     
- Complexity      104      134      +30     
============================================
  Files            34       44      +10     
  Lines           370      439      +69     
  Branches          7        8       +1     
============================================
+ Hits            293      360      +67     
- Misses           73       74       +1     
- Partials          4        5       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dukris dukris requested a review from h1alexbel February 16, 2024 10:26
Copy link
Collaborator

@h1alexbel h1alexbel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hizmailovich take a look, please

src/main/resources/db/changelog/2024/005-secrets.sql Outdated Show resolved Hide resolved
src/main/resources/sql/select-secret-by-key.sql Outdated Show resolved Hide resolved
@dukris dukris requested a review from h1alexbel February 19, 2024 16:42
Copy link
Collaborator

@h1alexbel h1alexbel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hizmailovich see below

final ResourceAlreadyExistsException exception
) {
log.warn(exception.getMessage(), exception);
return new ResponseEntity<>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets create a new class RestError that encapsulate the status and returns a Json document. This can help us to resolve code duplication. WDYT?

@RequestParam final UUID project,
@RequestParam final String key
) {
return this.secrets.value(project, key);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also should have an endpoint that returns a list of keys for secrets in the project. Lets create a puzzle for now

Copy link
Collaborator

@h1alexbel h1alexbel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hizmailovich
Also, we miss the functionality of updating secrets (new value for the same key) and value encryption (to keep passwords and other sensitive info safe.

Let's create a puzzles for this as well

@@ -36,6 +36,8 @@
/**
* Secret Controller.
*
* @todo #44:30min create an endpoint to list all secrets from the project.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should list their keys only

@h1alexbel
Copy link
Collaborator

@rultor merge

@rultor
Copy link
Collaborator

rultor commented Feb 20, 2024

@rultor merge

@h1alexbel Thanks for your request; @hizmailovich please confirm this.

@dukris
Copy link
Collaborator Author

dukris commented Feb 20, 2024

@rultor merge

@rultor
Copy link
Collaborator

rultor commented Feb 20, 2024

@rultor merge

@hizmailovich OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 786aafb into master Feb 20, 2024
8 checks passed
@dukris dukris deleted the 44 branch February 20, 2024 13:52
@rultor
Copy link
Collaborator

rultor commented Feb 20, 2024

@rultor merge

@hizmailovich Done! FYI, the full log is here (took me 3min)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API for storing secrets
4 participants