forked from octokit/octokit.net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated git data commit response with signature verification object (o…
- Loading branch information
Showing
13 changed files
with
121 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", "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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
/// <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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters