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 ssh keys fields on meta API response #1996

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/main/java/org/kohsuke/github/GHMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

// TODO: Auto-generated Javadoc
/**
* Class that wraps the list of GitHub's IP addresses.
*
* @author Paulo Miguel Almeida
* @see GitHub#getMeta() GitHub#getMeta()
* @see <a href="https://developer.github.com/v3/meta/#meta">Get Meta</a>
* @see <a href="https://docs.github.com/en/rest/meta/meta?apiVersion=2022-11-28#get-github-meta-information">Get
* Meta</a>
*/
public class GHMeta {

Expand All @@ -24,6 +26,10 @@ public GHMeta() {

@JsonProperty("verifiable_password_authentication")
private boolean verifiablePasswordAuthentication;
@JsonProperty("ssh_key_fingerprints")
private Map<String, String> sshKeyFingerprints;
@JsonProperty("ssh_keys")
private List<String> sshKeys;
private List<String> hooks;
private List<String> git;
private List<String> web;
Expand All @@ -43,6 +49,24 @@ public boolean isVerifiablePasswordAuthentication() {
return verifiablePasswordAuthentication;
}

/**
* Gets ssh key fingerprints.
*
* @return the ssh key fingerprints
*/
public Map<String, String> getSshKeyFingerprints() {
return Collections.unmodifiableMap(sshKeyFingerprints);
}

/**
* Gets ssh keys.
*
* @return the ssh keys
*/
public List<String> getSshKeys() {
return Collections.unmodifiableList(sshKeys);
}

/**
* Gets hooks.
*
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/kohsuke/github/GitHubTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ public void testListMyAuthorizations() throws IOException {
public void getMeta() throws IOException {
GHMeta meta = gitHub.getMeta();
assertThat(meta.isVerifiablePasswordAuthentication(), is(true));
assertThat(meta.getSshKeyFingerprints().size(), equalTo(4));
assertThat(meta.getSshKeys().size(), equalTo(3));
assertThat(meta.getApi().size(), equalTo(19));
assertThat(meta.getGit().size(), equalTo(36));
assertThat(meta.getHooks().size(), equalTo(4));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
"verifiable_password_authentication": true,
"ssh_key_fingerprints": {
"SHA256_RSA": 1234567890,
"SHA256_DSA": 1234567890,
"SHA256_ECDSA": 1234567890,
"SHA256_ED25519": 1234567890
},
"ssh_keys": [
"ssh-ed25519 ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"ecdsa-sha2-nistp256 ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZ"
],
"hooks": [
"192.30.252.0/22",
"185.199.108.0/22",
Expand Down
Loading