Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
20 changes: 16 additions & 4 deletions Octokit.Tests/Clients/MiscellaneousClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IApiConnection>();
Expand All @@ -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<Meta>(Arg.Is<Uri>(u => u.ToString() == "meta"));
Expand Down
50 changes: 48 additions & 2 deletions Octokit/Models/Response/Meta.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using Octokit.Internal;
Expand All @@ -24,23 +25,40 @@ public Meta()
/// <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>
Expand All @@ -54,6 +72,7 @@ public Meta(
/// 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>
Expand All @@ -63,11 +82,28 @@ public Meta(
/// </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>
Expand All @@ -78,6 +114,16 @@ public Meta(
/// </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
Expand Down