-
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 6 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using System.Threading.Tasks; | ||
using Octokit; | ||
using Octokit.Models.Response; | ||
using Octokit.Tests.Integration.Helpers; | ||
using Octokit.Tests.Integration; | ||
using Xunit; | ||
|
@@ -43,4 +44,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", "Signature-Verification", "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, VerificationReason.UnknownKey); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
using System.Collections.ObjectModel; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using 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. This shouldn't be necessary when the namespace is updated as per the other comment below... |
||
|
||
namespace Octokit | ||
{ | ||
|
@@ -34,5 +35,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,90 @@ | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using Octokit.Internal; | ||
|
||
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 VerificationReason 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 VerificationReason | ||
{ | ||
[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 comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned elsewhere, this should be unnecessary after renaming the namespace...