github-api icon indicating copy to clipboard operation
github-api copied to clipboard

Adding public key to user

Open vmax opened this issue 5 years ago • 6 comments

Describe the bug

It currently seems to be impossible to add a new public key to user's account using GHMyself. POST /user/keys is the relevant GitHub API endpoint.

To Reproduce Read docs on GHMyself and observe the method not being present

Expected behavior GHMyself::addKey to be available, with an interface similar to GHRepository::addDeployKey

vmax avatar Aug 26 '20 09:08 vmax

Hello, I would like to work on this issue. I will add a function GHMyself:addKey(title, key).
It it is alright, please can assign this issue to me.

badalsarkar avatar Oct 13 '20 16:10 badalsarkar

This would be nice to have!

eputnam avatar Oct 26 '20 17:10 eputnam

I was following this instruction. This mvn install -Dtest=WireMockStatusReporterTest works fine. But running mvn install -Dtest.github.useProxy -Dtest=WireMockStatusReporterTest gives the following error-

[INFO] Running org.kohsuke.github.WireMockStatusReporterTest
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

WireMockStatusReporterTest: GitHub proxying and user auth correctly configured for user login: badalsarkar

[ERROR] Tests run: 6, Failures: 1, Errors: 0, Skipped: 4, Time elapsed: 4.045 s <<< FAILURE! - in org.kohsuke.github.WireMockStatusReporterTest
[ERROR] BasicBehaviors_whenProxying(org.kohsuke.github.WireMockStatusReporterTest)  Time elapsed: 2.813 s  <<< FAILURE!
java.lang.AssertionError:

Expected: a string containing "{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/#get\"}"
     but: was "http://localhost:39169/repos/github-api/non-existant-repository {"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#get-a-repository"}"
        at org.kohsuke.github.AbstractGitHubWireMockTest.assertThat(AbstractGitHubWireMockTest.java:261)
        at org.kohsuke.github.AbstractGitHubWireMockTest.assertThat(AbstractGitHubWireMockTest.java:248)
        at org.kohsuke.github.WireMockStatusReporterTest.BasicBehaviors_whenProxying(WireMockStatusReporterTest.java:126)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
        at org.kohsuke.github.junit.WireMockMultiServerRule$1.evaluate(WireMockMultiServerRule.java:69)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
        at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)

[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   WireMockStatusReporterTest.BasicBehaviors_whenProxying:126->AbstractGitHubWireMockTest.assertThat:248->AbstractGitHubWireMockTest.assertThat:261
Expected: a string containing "{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/repos/#get\"}"
     but: was "http://localhost:39169/repos/github-api/non-existant-repository {"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#get-a-repository"}"
[INFO]

badalsarkar avatar Oct 27 '20 19:10 badalsarkar

@badalsarkar That is a bug in the WireMockStatusReporterTest.BasicBehaviors_whenProxying test.

bitwiseman avatar Nov 05 '20 18:11 bitwiseman

@badalsarkar It looks like the assertion was recently updated. Please make sure you are working based on the latest commit.

https://github.com/hub4j/github-api/blame/3a11b7ccbf5ef80e6231c15b539c5d386f827caf/src/test/java/org/kohsuke/github/WireMockStatusReporterTest.java#L128

bitwiseman avatar Nov 05 '20 18:11 bitwiseman

I was goting to do the same thing in GHMyself, then I found this post. What happened that make it still be open? 😂

verils avatar Jun 02 '22 10:06 verils