From 18ed2df4eb6bb75f117a89a4f9db2932372c1b77 Mon Sep 17 00:00:00 2001 From: Chris Simpson Date: Sat, 17 Sep 2022 18:37:04 +0100 Subject: [PATCH] Fixes the meta dto and meta tests so they pass and are fully the same as from github. Closes #2578# --- .../Clients/MiscellaneousClientTests.cs | 11 +++- .../Clients/MiscellaneousClientTests.cs | 20 ++++++-- Octokit/Models/Response/Meta.cs | 50 ++++++++++++++++++- 3 files changed, 73 insertions(+), 8 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs b/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs index 0dce4f856b..c671b730aa 100644 --- a/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs @@ -162,12 +162,19 @@ public async Task CanRetrieveMetadata() var result = await github.Miscellaneous.GetMetadata(); - Assert.True(result.VerifiablePasswordAuthentication); - Assert.NotEmpty(result.GitHubServicesSha); + Assert.False(result.VerifiablePasswordAuthentication); // is username password allowed, probably not any more +#pragma warning disable CS0618 // Type or member is obsolete + Assert.True(string.IsNullOrEmpty(result.GitHubServicesSha)); +#pragma warning restore CS0618 // Type or member is obsolete Assert.True(result.Hooks.Count > 0); + Assert.True(result.Web.Count > 0); + Assert.True(result.Api.Count > 0); Assert.True(result.Git.Count > 0); + Assert.True(result.Packages.Count > 0); Assert.True(result.Pages.Count > 0); Assert.True(result.Importer.Count > 0); + Assert.True(result.Actions.Count > 0); + Assert.True(result.Dependabot.Count > 0); } } } diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index 059316e354..09d120ad0d 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -151,7 +151,12 @@ public async Task RequestsTheMetadataEndpoint() 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" } + new[] { "1.1.4.1/24", "1.1.4.2/24" }, + new[] { "1.1.5.1/24", "1.1.5.2/24" }, + new[] { "1.1.6.1/24", "1.1.6.2/24" }, + new[] { "1.1.7.1", "1.1.7.2" }, + new[] { "1.1.8.1/24", "1.1.8.2/24" }, + new[] { "1.1.9.1", "1.1.9.2" } ); var apiConnection = Substitute.For(); @@ -161,11 +166,18 @@ public async Task RequestsTheMetadataEndpoint() var result = await client.GetMetadata(); Assert.False(result.VerifiablePasswordAuthentication); +#pragma warning disable CS0618 // Type or member is obsolete Assert.Equal("12345ABCDE", result.GitHubServicesSha); +#pragma warning restore CS0618 // Type or member is obsolete 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" }); + Assert.Equal(result.Web, new[] { "1.1.2.1/24", "1.1.2.2/24" }); + Assert.Equal(result.Api, new[] { "1.1.3.1/24", "1.1.3.2/24" }); + Assert.Equal(result.Git, new[] { "1.1.4.1/24", "1.1.4.2/24" }); + Assert.Equal(result.Packages, new[] { "1.1.5.1/24", "1.1.5.2/24" }); + Assert.Equal(result.Pages, new[] { "1.1.6.1/24", "1.1.6.2/24" }); + Assert.Equal(result.Importer, new[] { "1.1.7.1", "1.1.7.2" }); + Assert.Equal(result.Actions, new[] { "1.1.8.1/24", "1.1.8.2/24" }); + Assert.Equal(result.Dependabot, new[] { "1.1.9.1", "1.1.9.2" }); apiConnection.Received() .Get(Arg.Is(u => u.ToString() == "meta")); diff --git a/Octokit/Models/Response/Meta.cs b/Octokit/Models/Response/Meta.cs index 0dec38c95f..a5a8a644b4 100644 --- a/Octokit/Models/Response/Meta.cs +++ b/Octokit/Models/Response/Meta.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using Octokit.Internal; @@ -24,23 +25,40 @@ public Meta() /// Whether authentication with username and password is supported. /// The currently-deployed SHA of github-services. /// An array of IP addresses in CIDR format specifying the addresses that incoming service hooks will originate from on GitHub.com. + /// An array of IP addresses in CIDR format specifying the Web servers for GitHub + /// An array of IP addresses in CIDR format specifying the Api servers for GitHub /// An array of IP addresses in CIDR format specifying the Git servers for the GitHub server + /// An array of IP addresses in CIDR format specifying the Packages servers for GitHub /// An array of IP addresses in CIDR format specifying the A records for GitHub Pages. /// An Array of IP addresses specifying the addresses that source imports will originate from on GitHub.com. + /// An array of IP addresses in CIDR format specifying the Actions servers for GitHub + /// An array of IP addresses in CIDR format specifying the Dependabot servers for GitHub public Meta( bool verifiablePasswordAuthentication, string gitHubServicesSha, IReadOnlyList hooks, + IReadOnlyList web, + IReadOnlyList api, IReadOnlyList git, + IReadOnlyList packages, IReadOnlyList pages, - IReadOnlyList importer) + IReadOnlyList importer, + IReadOnlyList actions, + IReadOnlyList dependabot) { VerifiablePasswordAuthentication = verifiablePasswordAuthentication; +#pragma warning disable CS0618 // Type or member is obsolete GitHubServicesSha = gitHubServicesSha; +#pragma warning restore CS0618 // Type or member is obsolete Hooks = hooks; + Web = web; + Api = api; Git = git; + Packages = packages; Pages = pages; Importer = importer; + Actions = actions; + Dependabot = dependabot; } /// @@ -54,6 +72,7 @@ public Meta( /// The currently-deployed SHA of github-services. /// [Parameter(Key = "github_services_sha")] + [Obsolete("No longer returned so always null")] public string GitHubServicesSha { get; private set; } /// @@ -63,11 +82,28 @@ public Meta( /// public IReadOnlyList Hooks { get; private set; } + /// + /// An Array of IP addresses in CIDR format specifying the Web servers for GitHub.com. + /// + public IReadOnlyList Web { get; private set; } + + + /// + /// An Array of IP addresses in CIDR format specifying the Api servers for GitHub.com. + /// + public IReadOnlyList Api { get; private set; } + /// /// An Array of IP addresses in CIDR format specifying the Git servers for GitHub.com. /// public IReadOnlyList Git { get; private set; } + + /// + /// An Array of IP addresses in CIDR format specifying the Packages servers for GitHub.com. + /// + public IReadOnlyList Packages { get; private set; } + /// /// An Array of IP addresses in CIDR format specifying the A records for GitHub Pages. /// @@ -78,6 +114,16 @@ public Meta( /// public IReadOnlyList Importer { get; private set; } + /// + /// An Array of IP addresses in CIDR format specifying the Actions servers. + /// + public IReadOnlyList Actions { get; private set; } + + /// + /// An Array of IP addresses in CIDR format specifying the Dependabot servers. + /// + public IReadOnlyList Dependabot { get; private set; } + internal string DebuggerDisplay { get