mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Updated git data commit response with signature verification object (#1398)
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
<Word>Tarball</Word>
|
<Word>Tarball</Word>
|
||||||
<Word>Unsuspend</Word>
|
<Word>Unsuspend</Word>
|
||||||
<Word>Zipball</Word>
|
<Word>Zipball</Word>
|
||||||
|
<Word>Gpg</Word>
|
||||||
</Recognized>
|
</Recognized>
|
||||||
</Words>
|
</Words>
|
||||||
<Acronyms>
|
<Acronyms>
|
||||||
|
|||||||
@@ -43,4 +43,21 @@ public class CommitsClientTests
|
|||||||
Assert.NotNull(retrieved);
|
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 <SarmadSattar1@gmail.com> 1465990529 +0500\ncommitter noonari <SarmadSattar1@gmail.com> 1465990529 +0500\n\ngpg stuff\n");
|
||||||
|
|
||||||
|
Assert.Equal(commit.Verification.Reason, VerificationReason.UnknownKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ public class CommitsClientTests
|
|||||||
|
|
||||||
client.Get("owner", "repo", "reference");
|
client.Get("owner", "repo", "reference");
|
||||||
|
|
||||||
connection.Received().Get<Commit>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/commits/reference"));
|
connection.Received().Get<Commit>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/commits/reference"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.cryptographer-preview+sha");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace Octokit
|
|||||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||||
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
|
||||||
|
|
||||||
return ApiConnection.Get<Commit>(ApiUrls.Commit(owner, name, reference));
|
return ApiConnection.Get<Commit>(ApiUrls.Commit(owner, name, reference), null, AcceptHeaders.SignatureVerificationPreview);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ namespace Octokit
|
|||||||
|
|
||||||
public const string ReactionsPreview = "application/vnd.github.squirrel-girl-preview";
|
public const string ReactionsPreview = "application/vnd.github.squirrel-girl-preview";
|
||||||
|
|
||||||
|
public const string SignatureVerificationPreview = "application/vnd.github.cryptographer-preview+sha";
|
||||||
|
|
||||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
|
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
|
||||||
public const string GpgKeysPreview = "application/vnd.github.cryptographer-preview";
|
public const string GpgKeysPreview = "application/vnd.github.cryptographer-preview";
|
||||||
|
|
||||||
|
|||||||
@@ -34,5 +34,7 @@ namespace Octokit
|
|||||||
public IReadOnlyList<GitReference> Parents { get; protected set; }
|
public IReadOnlyList<GitReference> Parents { get; protected set; }
|
||||||
|
|
||||||
public int CommentCount { get; protected set; }
|
public int CommentCount { get; protected set; }
|
||||||
|
|
||||||
|
public Verification Verification { get; protected set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
90
Octokit/Models/Response/Verification.cs
Normal file
90
Octokit/Models/Response/Verification.cs
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -484,6 +484,7 @@
|
|||||||
<Compile Include="Clients\UserGpgKeysClient.cs" />
|
<Compile Include="Clients\UserGpgKeysClient.cs" />
|
||||||
<Compile Include="Models\Request\NewGpgKey.cs" />
|
<Compile Include="Models\Request\NewGpgKey.cs" />
|
||||||
<Compile Include="Models\Response\GpgKey.cs" />
|
<Compile Include="Models\Response\GpgKey.cs" />
|
||||||
|
<Compile Include="Models\Response\Verification.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -495,6 +495,7 @@
|
|||||||
<Compile Include="Models\Request\NewGpgKey.cs" />
|
<Compile Include="Models\Request\NewGpgKey.cs" />
|
||||||
<Compile Include="Models\Response\GpgKey.cs" />
|
<Compile Include="Models\Response\GpgKey.cs" />
|
||||||
<Compile Include="Models\Response\ReactionSummary.cs" />
|
<Compile Include="Models\Response\ReactionSummary.cs" />
|
||||||
|
<Compile Include="Models\Response\Verification.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -491,6 +491,7 @@
|
|||||||
<Compile Include="Models\Request\NewGpgKey.cs" />
|
<Compile Include="Models\Request\NewGpgKey.cs" />
|
||||||
<Compile Include="Models\Response\GpgKey.cs" />
|
<Compile Include="Models\Response\GpgKey.cs" />
|
||||||
<Compile Include="Models\Response\ReactionSummary.cs" />
|
<Compile Include="Models\Response\ReactionSummary.cs" />
|
||||||
|
<Compile Include="Models\Response\Verification.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
|||||||
@@ -481,6 +481,7 @@
|
|||||||
<Compile Include="Models\Request\NewGpgKey.cs" />
|
<Compile Include="Models\Request\NewGpgKey.cs" />
|
||||||
<Compile Include="Models\Response\GpgKey.cs" />
|
<Compile Include="Models\Response\GpgKey.cs" />
|
||||||
<Compile Include="Models\Response\ReactionSummary.cs" />
|
<Compile Include="Models\Response\ReactionSummary.cs" />
|
||||||
|
<Compile Include="Models\Response\Verification.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||||
|
|||||||
@@ -488,6 +488,7 @@
|
|||||||
<Compile Include="Models\Request\NewGpgKey.cs" />
|
<Compile Include="Models\Request\NewGpgKey.cs" />
|
||||||
<Compile Include="Models\Response\GpgKey.cs" />
|
<Compile Include="Models\Response\GpgKey.cs" />
|
||||||
<Compile Include="Models\Response\ReactionSummary.cs" />
|
<Compile Include="Models\Response\ReactionSummary.cs" />
|
||||||
|
<Compile Include="Models\Response\Verification.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||||
|
|||||||
@@ -394,6 +394,7 @@
|
|||||||
<Compile Include="Models\Common\Committer.cs" />
|
<Compile Include="Models\Common\Committer.cs" />
|
||||||
<Compile Include="Models\Response\TagObject.cs" />
|
<Compile Include="Models\Response\TagObject.cs" />
|
||||||
<Compile Include="Models\Response\AccountType.cs" />
|
<Compile Include="Models\Response\AccountType.cs" />
|
||||||
|
<Compile Include="Models\Response\Verification.cs" />
|
||||||
<Compile Include="Models\Response\WeeklyCommitActivity.cs" />
|
<Compile Include="Models\Response\WeeklyCommitActivity.cs" />
|
||||||
<Compile Include="Models\Response\Participation.cs" />
|
<Compile Include="Models\Response\Participation.cs" />
|
||||||
<Compile Include="Models\Response\WeeklyHash.cs" />
|
<Compile Include="Models\Response\WeeklyHash.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user