From a489092f62fe31b0b6033f11296ed7316382477c Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 3 Apr 2016 21:56:30 +1000 Subject: [PATCH] Add Importer property to Meta response model Implement unit test for GetMetadata() call Flesh out integration test to check all returned Meta fields -> Found and fixed a bug where the existing `GitHubServicesSHA` field was not deserialised properly --- .../Clients/MiscellaneousClientTests.cs | 5 +++ .../Clients/MiscellaneousClientTests.cs | 36 +++++++++++++++++++ Octokit/Models/Response/Meta.cs | 11 +++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs b/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs index b13fd3a9..a6ec1944 100644 --- a/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs @@ -113,6 +113,11 @@ public class MiscellaneousClientTests var result = await github.Miscellaneous.GetMetadata(); Assert.True(result.VerifiablePasswordAuthentication); + Assert.NotEmpty(result.GitHubServicesSha); + Assert.True(result.Hooks.Count > 0); + Assert.True(result.Git.Count > 0); + Assert.True(result.Pages.Count > 0); + Assert.True(result.Importer.Count > 0); } } } \ No newline at end of file diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index 7b9a0f2b..088b33ad 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -136,6 +136,42 @@ namespace Octokit.Tests.Clients } } + public class TheGetMetadataMethod + { + [Fact] + public async Task RequestsTheMetadataEndpoint() + { + IApiResponse response = new ApiResponse + ( + new Response(), + new Meta( + false, + "12345ABCDE", + new[] { "1.1.1.1/24", "1.1.1.2/24" }, + new[] { "1.1.2.1/24", "1.1.2.2/24" }, + new[] { "1.1.3.1/24", "1.1.3.2/24" }, + new[] { "1.1.4.1", "1.1.4.2" } + ) + ); + var connection = Substitute.For(); + connection.Get(Args.Uri, null, null) + .Returns(Task.FromResult(response)); + var client = new MiscellaneousClient(connection); + + var result = await client.GetMetadata(); + + Assert.Equal(result.VerifiablePasswordAuthentication, false); + Assert.Equal(result.GitHubServicesSha, "12345ABCDE"); + Assert.Equal(result.Hooks, new[] { "1.1.1.1/24", "1.1.1.2/24" }); + Assert.Equal(result.Git, new[] { "1.1.2.1/24", "1.1.2.2/24" }); + Assert.Equal(result.Pages, new[] { "1.1.3.1/24", "1.1.3.2/24" }); + Assert.Equal(result.Importer, new[] { "1.1.4.1", "1.1.4.2" }); + + connection.Received() + .Get(Arg.Is(u => u.ToString() == "meta"), null, null); + } + } + public class TheCtor { [Fact] diff --git a/Octokit/Models/Response/Meta.cs b/Octokit/Models/Response/Meta.cs index 3d388827..a6211110 100644 --- a/Octokit/Models/Response/Meta.cs +++ b/Octokit/Models/Response/Meta.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; +using Octokit.Internal; namespace Octokit { @@ -30,13 +31,15 @@ namespace Octokit string gitHubServicesSha, IReadOnlyList hooks, IReadOnlyList git, - IReadOnlyList pages) + IReadOnlyList pages, + IReadOnlyList importer) { VerifiablePasswordAuthentication = verifiablePasswordAuthentication; GitHubServicesSha = gitHubServicesSha; Hooks = hooks; Git = git; Pages = pages; + Importer = importer; } /// @@ -49,6 +52,7 @@ namespace Octokit /// /// The currently-deployed SHA of github-services. /// + [Parameter(Key = "github_services_sha")] public string GitHubServicesSha { get; private set; } /// @@ -68,6 +72,11 @@ namespace Octokit /// public IReadOnlyList Pages { get; private set; } + /// + /// An Array of IP addresses specifying the addresses that source imports will originate from on GitHub.com. + /// + public IReadOnlyList Importer { get; private set; } + internal string DebuggerDisplay { get