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

Add created_at and last_used fields to DeployKey. #1593

Closed
wants to merge 14 commits into from
Closed

Add created_at and last_used fields to DeployKey. #1593

wants to merge 14 commits into from

Conversation

van-vliet
Copy link
Contributor

@van-vliet van-vliet commented Jan 9, 2023

https://docs.github.com/en/rest/deploy-keys?apiVersion=2022-11-28#get-a-deploy-key

Description

I need to rotate all GH deploy keys that are older than a certain age. Today that is not possible since the created date is not part of the Deploy Key class. This PR adds the created_at and last_used fields to allow users to read these values.

Before submitting a PR:

  • Changes must not break binary backwards compatibility. If you are unclear on how to make the change you think is needed while maintaining backward compatibility, CONTRIBUTING.md for details.
  • Add JavaDocs and other comments as appropriate. Consider including links in comments to relevant documentation on https://docs.github.com/en/rest .
  • Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See CONTRIBUTING.md for details.
  • Run mvn -D enable-ci clean install site locally. If this command doesn't succeed, your change will not pass CI.
  • Push your changes to a branch other than main. You will create your PR from that branch.

When creating a PR:

  • Fill in the "Description" above with clear summary of the changes. This includes:
    • If this PR fixes one or more issues, include "Fixes #" lines for each issue.
    • Provide links to relevant documentation on https://docs.github.com/en/rest where possible.
  • All lines of new code should be covered by tests as reported by code coverage. Any lines that are not covered must have PR comments explaining why they cannot be covered. For example, "Reaching this particular exception is hard and is not a particular common scenario."

There are no tests for deploy keys at all. Since this PR only adds to fields, I haven't added any.

  • Enable "Allow edits from maintainers".
    I followed the description here but the "Allow edits from maintainers" checkbox is not visible.

@codecov
Copy link

codecov bot commented Jan 12, 2023

Codecov Report

Base: 79.22% // Head: 79.28% // Increases project coverage by +0.05% 🎉

Coverage data is based on head (2b8f3b2) compared to base (612f5ec).
Patch coverage: 55.00% of modified lines in pull request are covered.

❗ Current head 2b8f3b2 differs from pull request most recent head 001e7c0. Consider uploading reports for the commit 001e7c0 to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1593      +/-   ##
============================================
+ Coverage     79.22%   79.28%   +0.05%     
- Complexity     2141     2151      +10     
============================================
  Files           206      206              
  Lines          6576     6595      +19     
  Branches        364      364              
============================================
+ Hits           5210     5229      +19     
  Misses         1154     1154              
  Partials        212      212              
Impacted Files Coverage Δ
src/main/java/org/kohsuke/github/GHDeployKey.java 25.92% <25.00%> (+25.92%) ⬆️
src/main/java/org/kohsuke/github/GHKey.java 100.00% <100.00%> (ø)
src/main/java/org/kohsuke/github/GHMyself.java 45.61% <100.00%> (+6.39%) ⬆️
src/main/java/org/kohsuke/github/GHRepository.java 69.72% <0.00%> (+0.61%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@bitwiseman
Copy link
Member

Looking good. Please include in testing.

@van-vliet
Copy link
Contributor Author

Will do @bitwiseman . I've requested access to the testing organization here: #1602

@van-vliet
Copy link
Contributor Author

@bitwiseman I've added functionality to add public keys to the user in this PR as well. I've added test cases for the things added by this PR. I need to create wiremocks and update a few assertions once I'm able to create the test repository in the hub4j-test-org organization.

@bitwiseman
Copy link
Member

@van-vliet
Invited. Thanks!

…ted key timestamps to match the ones in that repo.

Snapshotted the wiremocks.
@van-vliet
Copy link
Contributor Author

The test are ready. @bitwiseman Can you approve the CI builds so that we can see whether the tests pass on the CI server and whether code coverage is high enough.

Use a constant public key since it is not added to the actual users account unless someone actively decides to refresh the snapshot.
@van-vliet
Copy link
Contributor Author

Tests should work without use of proxy. Javadoc warnings that caused the site to fail have also been fixed. @bitwiseman can you approve running the CI tests?

@van-vliet
Copy link
Contributor Author

(hopefully) one last time please.

@van-vliet
Copy link
Contributor Author

Code coverage should be fixed now as well. Please try again.

@van-vliet
Copy link
Contributor Author

@bitwiseman can you trigger the CI builds again?

Also, it seems

  • Enable "Allow edits from maintainers".

can only be enabled if the PR comes from a personal account. This PR comes from my work organization. Do I need to recreate the PR from my personal account instead?

@van-vliet
Copy link
Contributor Author

Recreated PR from personal account to allow enabling "Allow edits from maintainers":
#1616

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.

None yet

2 participants