Skip to content

Commit 4f505a5

Browse files
authored
Add ssh keys fields on meta API response (#1996)
1 parent 58dcca1 commit 4f505a5

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/main/java/org/kohsuke/github/GHMeta.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
import java.util.ArrayList;
66
import java.util.Collections;
77
import java.util.List;
8+
import java.util.Map;
89

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

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

2527
@JsonProperty("verifiable_password_authentication")
2628
private boolean verifiablePasswordAuthentication;
29+
@JsonProperty("ssh_key_fingerprints")
30+
private Map<String, String> sshKeyFingerprints;
31+
@JsonProperty("ssh_keys")
32+
private List<String> sshKeys;
2733
private List<String> hooks;
2834
private List<String> git;
2935
private List<String> web;
@@ -43,6 +49,24 @@ public boolean isVerifiablePasswordAuthentication() {
4349
return verifiablePasswordAuthentication;
4450
}
4551

52+
/**
53+
* Gets ssh key fingerprints.
54+
*
55+
* @return the ssh key fingerprints
56+
*/
57+
public Map<String, String> getSshKeyFingerprints() {
58+
return Collections.unmodifiableMap(sshKeyFingerprints);
59+
}
60+
61+
/**
62+
* Gets ssh keys.
63+
*
64+
* @return the ssh keys
65+
*/
66+
public List<String> getSshKeys() {
67+
return Collections.unmodifiableList(sshKeys);
68+
}
69+
4670
/**
4771
* Gets hooks.
4872
*

src/test/java/org/kohsuke/github/GitHubTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ public void testListMyAuthorizations() throws IOException {
283283
public void getMeta() throws IOException {
284284
GHMeta meta = gitHub.getMeta();
285285
assertThat(meta.isVerifiablePasswordAuthentication(), is(true));
286+
assertThat(meta.getSshKeyFingerprints().size(), equalTo(4));
287+
assertThat(meta.getSshKeys().size(), equalTo(3));
286288
assertThat(meta.getApi().size(), equalTo(19));
287289
assertThat(meta.getGit().size(), equalTo(36));
288290
assertThat(meta.getHooks().size(), equalTo(4));

src/test/resources/org/kohsuke/github/GitHubTest/wiremock/getMeta/__files/1-meta.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
{
22
"verifiable_password_authentication": true,
3+
"ssh_key_fingerprints": {
4+
"SHA256_RSA": 1234567890,
5+
"SHA256_DSA": 1234567890,
6+
"SHA256_ECDSA": 1234567890,
7+
"SHA256_ED25519": 1234567890
8+
},
9+
"ssh_keys": [
10+
"ssh-ed25519 ABCDEFGHIJKLMNOPQRSTUVWXYZ",
11+
"ecdsa-sha2-nistp256 ABCDEFGHIJKLMNOPQRSTUVWXYZ",
12+
"ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZ"
13+
],
314
"hooks": [
415
"192.30.252.0/22",
516
"185.199.108.0/22",

0 commit comments

Comments
 (0)