-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Updated git data commit response with signature verification object #1398
Changes from 2 commits
771415e
484b63a
bb2338f
711c5de
46a81af
3b941d9
6e1ded0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,21 @@ public async Task CanCreateAndRetrieveCommit() | |
Assert.NotNull(retrieved); | ||
} | ||
} | ||
|
||
[IntegrationTest] | ||
public async Task CanDeserializeVerificationObjectInResponse() | ||
{ | ||
var github = Helper.GetAuthenticatedClient(); | ||
|
||
var commit = await github.Git.Commit.Get("noonari", "source-repo-20160517084127190", "1965d149ce1151cf411300d15f8d890d9259bd21"); | ||
|
||
Assert.False(commit.Verification.Verified); | ||
Assert.Equal(commit.Verification.Signature, | ||
"-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1\n\niQEcBAABAgAGBQJXYT2BAAoJEJyZ1vxIV0+N9ZwIAKlf3dk9n1q1mD5AT3Ahtj9o\nF4H25zsHynJk2lnH4YxVvDBEc/uMCXzX6orihZiSdA5UXE7tPyEEZddQdp8pxulX\ncIsFKcrfQqHJnTbT90z5PhAk94lyN9fFngzPW1tgZZVjp2YiiqgXduBWWm6EREOh\nS1Iu9wBqScQomhTXoksmNZyGTZ0LviSi0pkqRY64pQhKnpLlu1OFXaeDvhYocB+E\nY5URZsXodvIkBuzCkWCu8ra4eaXIIARkas4+jIvn0FIx9CzEVz0Zau/5Fk+BR+Te\n7a3/7JH7yuObPB0hqPSuFYyxtvPfxtayvhkGD3YkQqDAkWCpISGyVFzxrrC7z0Y=\n=kbih\n-----END PGP SIGNATURE-----"); | ||
|
||
Assert.Equal(commit.Verification.Payload, | ||
"tree c91c844f37974093a3f0a864755441b577e7663a\nparent 6eb645f6badd46de65700b4d7b6fcdb97684ce5a\nauthor noonari <[email protected]> 1465990529 +0500\ncommitter noonari <[email protected]> 1465990529 +0500\n\ngpg stuff\n"); | ||
|
||
Assert.Equal(commit.Verification.Reason.ToString(), "UnknownKey"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💄 why not compare both enums here? |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,9 @@ public static class AcceptHeaders | |
public const string MigrationsApiPreview = "application/vnd.github.wyandotte-preview+json"; | ||
|
||
public const string ReactionsPreview = "application/vnd.github.squirrel-girl-preview"; | ||
|
||
|
||
public const string SignatureVerification = "application/vnd.github.cryptographer-preview+sha"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe name this |
||
|
||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")] | ||
public const string GpgKeysPreview = "application/vnd.github.cryptographer-preview"; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
using System.Collections.Generic; | ||
using Octokit.Internal; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💄 reorder these so |
||
using Octokit.Models.Response; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
|
@@ -34,5 +36,7 @@ public Commit(string url, string label, string @ref, string sha, User user, Repo | |
public IReadOnlyList<GitReference> Parents { get; protected set; } | ||
|
||
public int CommentCount { get; protected set; } | ||
|
||
public Verification Verification { get; protected set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using Octokit.Internal; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💄 ordering There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok... |
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Octokit.Models.Response | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a coding convention here that I guess needs to be documented properly. Despite these files living in |
||
{ | ||
/// <summary> | ||
/// Represents a Signature Verification Object in Git Data Commit Payload. | ||
/// </summary> | ||
[DebuggerDisplay("{DebuggerDisplay,nq}")] | ||
public class Verification | ||
{ | ||
/// <summary> | ||
/// Does GitHub consider the signature in this commit to be verified? | ||
/// </summary> | ||
public bool Verified { get; protected set; } | ||
|
||
/// <summary> | ||
/// The reason for verified value. | ||
/// </summary> | ||
[Parameter(Key = "reason")] | ||
public Reason Reason { get; protected set; } | ||
|
||
/// <summary> | ||
/// The signature that was extracted from the commit. | ||
/// </summary> | ||
public string Signature { get; protected set; } | ||
|
||
/// <summary> | ||
/// The value that was signed. | ||
/// </summary> | ||
public string Payload { get; protected set; } | ||
|
||
internal string DebuggerDisplay | ||
{ | ||
get | ||
{ | ||
return string.Format( | ||
CultureInfo.InvariantCulture, | ||
"Verification: {0} Verified: {1} Reason: {2} Signature: {3} Payload", | ||
Verified, | ||
Reason.ToString(), | ||
Signature, | ||
Payload); | ||
} | ||
} | ||
} | ||
|
||
public enum Reason | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right. fixing this. 👍 |
||
{ | ||
[Parameter(Value = "expired_key")] | ||
ExpiredKey, | ||
|
||
[Parameter(Value = "not_signing_key")] | ||
NotSigningKey, | ||
|
||
[Parameter(Value = "gpgverify_error")] | ||
GpgVerifyError, | ||
|
||
[Parameter(Value = "gpgverify_unavailable")] | ||
GpgVerifyUnavailable, | ||
|
||
[Parameter(Value = "unsigned")] | ||
Unsigned, | ||
|
||
[Parameter(Value = "unknown_signature_type")] | ||
UnknownSignatureType, | ||
|
||
[Parameter(Value = "no_user")] | ||
NoUser, | ||
|
||
[Parameter(Value = "unverified_email")] | ||
UnverifiedEmail, | ||
|
||
[Parameter(Value = "bad_email")] | ||
BadEmail, | ||
|
||
[Parameter(Value = "unknown_key")] | ||
UnknownKey, | ||
|
||
[Parameter(Value = "malformed_signature")] | ||
MalformedSignature, | ||
|
||
[Parameter(Value = "inavlid")] | ||
Invalid, | ||
|
||
[Parameter(Value = "valid")] | ||
Valid | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra whitespace line here |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth renaming this repository to make it's purpose more clear?