Fixes the meta dto and meta tests so they pass and are fully the same… (#2579)

This commit is contained in:
Chris Simpson
2022-09-20 21:17:48 +01:00
committed by GitHub
parent 2701be5e79
commit 3e5c5496b9
3 changed files with 73 additions and 8 deletions
@@ -162,12 +162,19 @@ public class MiscellaneousClientTests
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);
}
}
}
@@ -151,7 +151,12 @@ namespace Octokit.Tests.Clients
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<IApiConnection>();
@@ -161,11 +166,18 @@ namespace Octokit.Tests.Clients
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<Meta>(Arg.Is<Uri>(u => u.ToString() == "meta"));
+48 -2
View File
@@ -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 @@ namespace Octokit
/// <param name="verifiablePasswordAuthentication">Whether authentication with username and password is supported.</param>
/// <param name="gitHubServicesSha">The currently-deployed SHA of github-services.</param>
/// <param name="hooks">An array of IP addresses in CIDR format specifying the addresses that incoming service hooks will originate from on GitHub.com.</param>
/// <param name="web">An array of IP addresses in CIDR format specifying the Web servers for GitHub</param>
/// <param name="api">An array of IP addresses in CIDR format specifying the Api servers for GitHub</param>
/// <param name="git">An array of IP addresses in CIDR format specifying the Git servers for the GitHub server</param>
/// <param name="packages">An array of IP addresses in CIDR format specifying the Packages servers for GitHub</param>
/// <param name="pages">An array of IP addresses in CIDR format specifying the A records for GitHub Pages.</param>
/// <param name="importer">An Array of IP addresses specifying the addresses that source imports will originate from on GitHub.com.</param>
/// <param name="actions">An array of IP addresses in CIDR format specifying the Actions servers for GitHub</param>
/// <param name="dependabot">An array of IP addresses in CIDR format specifying the Dependabot servers for GitHub</param>
public Meta(
bool verifiablePasswordAuthentication,
string gitHubServicesSha,
IReadOnlyList<string> hooks,
IReadOnlyList<string> web,
IReadOnlyList<string> api,
IReadOnlyList<string> git,
IReadOnlyList<string> packages,
IReadOnlyList<string> pages,
IReadOnlyList<string> importer)
IReadOnlyList<string> importer,
IReadOnlyList<string> actions,
IReadOnlyList<string> 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;
}
/// <summary>
@@ -54,6 +72,7 @@ namespace Octokit
/// The currently-deployed SHA of github-services.
/// </summary>
[Parameter(Key = "github_services_sha")]
[Obsolete("No longer returned so always null")]
public string GitHubServicesSha { get; private set; }
/// <summary>
@@ -63,11 +82,28 @@ namespace Octokit
/// </summary>
public IReadOnlyList<string> Hooks { get; private set; }
/// <summary>
/// An Array of IP addresses in CIDR format specifying the Web servers for GitHub.com.
/// </summary>
public IReadOnlyList<string> Web { get; private set; }
/// <summary>
/// An Array of IP addresses in CIDR format specifying the Api servers for GitHub.com.
/// </summary>
public IReadOnlyList<string> Api { get; private set; }
/// <summary>
/// An Array of IP addresses in CIDR format specifying the Git servers for GitHub.com.
/// </summary>
public IReadOnlyList<string> Git { get; private set; }
/// <summary>
/// An Array of IP addresses in CIDR format specifying the Packages servers for GitHub.com.
/// </summary>
public IReadOnlyList<string> Packages { get; private set; }
/// <summary>
/// An Array of IP addresses in CIDR format specifying the A records for GitHub Pages.
/// </summary>
@@ -78,6 +114,16 @@ namespace Octokit
/// </summary>
public IReadOnlyList<string> Importer { get; private set; }
/// <summary>
/// An Array of IP addresses in CIDR format specifying the Actions servers.
/// </summary>
public IReadOnlyList<string> Actions { get; private set; }
/// <summary>
/// An Array of IP addresses in CIDR format specifying the Dependabot servers.
/// </summary>
public IReadOnlyList<string> Dependabot { get; private set; }
internal string DebuggerDisplay
{
get