Skip to content

Commit

Permalink
Add ssh keys fields on meta API response (#1996)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesbusy authored Dec 18, 2024
1 parent 58dcca1 commit 4f505a5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
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

0 comments on commit 4f505a5

Please sign in to comment.