From 61fa9d4376dee2285728104100b54734dec01e57 Mon Sep 17 00:00:00 2001 From: Matisse Hack Date: Tue, 29 Nov 2022 23:13:53 -0800 Subject: [PATCH 1/2] Add missing properties for meta and app payloads --- Octokit.Tests/Clients/MetaClientTests.cs | 3 +- .../Clients/MiscellaneousClientTests.cs | 3 +- Octokit/Models/Response/GitHubApp.cs | 15 +- .../Response/InstallationPermissions.cs | 215 ++++++++++++++---- Octokit/Models/Response/Meta.cs | 12 +- 5 files changed, 203 insertions(+), 45 deletions(-) diff --git a/Octokit.Tests/Clients/MetaClientTests.cs b/Octokit.Tests/Clients/MetaClientTests.cs index 9e5b5b584b..212066871e 100644 --- a/Octokit.Tests/Clients/MetaClientTests.cs +++ b/Octokit.Tests/Clients/MetaClientTests.cs @@ -23,7 +23,8 @@ public async Task RequestsTheMetadataEndpoint() 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" } + new[] { "1.1.9.1", "1.1.9.2" }, + null ); diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index c7a974f63e..5ddac79377 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -156,7 +156,8 @@ public async Task RequestsTheMetadataEndpoint() 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" } + new[] { "1.1.9.1", "1.1.9.2" }, + null ); var apiConnection = Substitute.For(); diff --git a/Octokit/Models/Response/GitHubApp.cs b/Octokit/Models/Response/GitHubApp.cs index d511450340..f1dbc49c70 100644 --- a/Octokit/Models/Response/GitHubApp.cs +++ b/Octokit/Models/Response/GitHubApp.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -12,7 +13,7 @@ public class GitHubApp { public GitHubApp() { } - public GitHubApp(long id, string slug, string name, User owner, string description, string externalUrl, string htmlUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt) + public GitHubApp(long id, string slug, string name, User owner, string description, string externalUrl, string htmlUrl, DateTimeOffset createdAt, DateTimeOffset updatedAt, InstallationPermissions permissions, IReadOnlyList events) { Id = id; Slug = slug; @@ -23,6 +24,8 @@ public GitHubApp(long id, string slug, string name, User owner, string descripti HtmlUrl = htmlUrl; CreatedAt = createdAt; UpdatedAt = updatedAt; + Permissions = permissions; + Events = events; } /// @@ -70,6 +73,16 @@ public GitHubApp(long id, string slug, string name, User owner, string descripti /// public DateTimeOffset UpdatedAt { get; private set; } + /// + /// The Permissions granted to the Installation + /// + public InstallationPermissions Permissions { get; private set; } + + /// + /// The Events subscribed to by the Installation + /// + public IReadOnlyList Events { get; private set; } + internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Id: {0} Name: {1}", Id, Name); } diff --git a/Octokit/Models/Response/InstallationPermissions.cs b/Octokit/Models/Response/InstallationPermissions.cs index fb407f4943..b45fe0bab2 100644 --- a/Octokit/Models/Response/InstallationPermissions.cs +++ b/Octokit/Models/Response/InstallationPermissions.cs @@ -9,111 +9,246 @@ public class InstallationPermissions { public InstallationPermissions() { } - public InstallationPermissions(InstallationPermissionLevel? metadata, InstallationPermissionLevel? administration, InstallationPermissionLevel? statuses, InstallationPermissionLevel? deployments, InstallationPermissionLevel? issues, InstallationPermissionLevel? pages, InstallationPermissionLevel? pullRequests, InstallationPermissionLevel? contents, InstallationPermissionLevel? singleFile, InstallationPermissionLevel? repositoryProjects, InstallationPermissionLevel? members, InstallationPermissionLevel? organizationProjects, InstallationPermissionLevel? teamDiscussions, InstallationPermissionLevel? checks) + public InstallationPermissions + ( + InstallationPermissionLevel? actions, + InstallationPermissionLevel? administration, + InstallationPermissionLevel? checks, + InstallationPermissionLevel? contents, + InstallationPermissionLevel? deployments, + InstallationPermissionLevel? environments, + InstallationPermissionLevel? issues, + InstallationPermissionLevel? metadata, + InstallationPermissionLevel? packages, + InstallationPermissionLevel? pages, + InstallationPermissionLevel? pullRequests, + InstallationPermissionLevel? repositoryAnnouncementBanners, + InstallationPermissionLevel? repositoryHooks, + InstallationPermissionLevel? repositoryProjects, + InstallationPermissionLevel? secretScanningAlerts, + InstallationPermissionLevel? secrets, + InstallationPermissionLevel? securityEvents, + InstallationPermissionLevel? singleFile, + InstallationPermissionLevel? statuses, + InstallationPermissionLevel? vulnerabilityAlerts, + InstallationPermissionLevel? workflows, + InstallationPermissionLevel? members, + InstallationPermissionLevel? organizationAdministration, + InstallationPermissionLevel? organizationCustomRoles, + InstallationPermissionLevel? organizationAnnouncementBanners, + InstallationPermissionLevel? organizationHooks, + InstallationPermissionLevel? organizationPlan, + InstallationPermissionLevel? organizationProjects, + InstallationPermissionLevel? organizationPackages, + InstallationPermissionLevel? organizationSecrets, + InstallationPermissionLevel? organizationSelfHostedRunners, + InstallationPermissionLevel? organizationUserBlocking, + InstallationPermissionLevel? teamDiscussions + ) { - Metadata = metadata; + Actions = actions; Administration = administration; - Statuses = statuses; + Checks = checks; + Contents = contents; Deployments = deployments; + Environments = environments; Issues = issues; + Metadata = metadata; + Packages = packages; Pages = pages; PullRequests = pullRequests; - Contents = contents; - SingleFile = singleFile; + RepositoryAnnouncementBanners = repositoryAnnouncementBanners; + RepositoryHooks = repositoryHooks; RepositoryProjects = repositoryProjects; + SecretScanningAlerts = secretScanningAlerts; + Secrets = secrets; + SecurityEvents = securityEvents; + SingleFile = singleFile; + Statuses = statuses; + VulnerabilityAlerts = vulnerabilityAlerts; + Workflows = workflows; Members = members; + OrganizationAdministration = organizationAdministration; + OrganizationCustomRoles = organizationCustomRoles; + OrganizationAnnouncementBanners = organizationAnnouncementBanners; + OrganizationHooks = organizationHooks; + OrganizationPlan = organizationPlan; OrganizationProjects = organizationProjects; + OrganizationPackages = organizationPackages; + OrganizationSecrets = organizationSecrets; + OrganizationSelfHostedRunners = organizationSelfHostedRunners; + OrganizationUserBlocking = organizationUserBlocking; TeamDiscussions = teamDiscussions; - Checks = checks; } /// - /// Repository metadata - /// Search repositories, list collaborators, and access repository metadata. + /// The level of permission to grant the access token for GitHub Actions workflows, workflow runs, and artifacts. /// - public StringEnum? Metadata { get; private set; } + public StringEnum? Actions { get; private set; } /// - /// Repository administration - /// Repository creation, deletion, settings, teams, and collaborators. + /// The level of permission to grant the access token for repository creation, deletion, settings, teams, and collaborators creation. /// public StringEnum? Administration { get; private set; } /// - /// Commit statuses - /// Commit statuses. + /// The level of permission to grant the access token for checks on code. /// - public StringEnum? Statuses { get; private set; } + public StringEnum? Checks { get; private set; } + + /// + /// The level of permission to grant the access token for repository contents, commits, branches, downloads, releases, and merges. + /// + public StringEnum? Contents { get; private set; } /// - /// Deployments - /// Deployments and deployment statuses. + /// The level of permission to grant the access token for deployments and deployment statuses. /// public StringEnum? Deployments { get; private set; } /// - /// Issues - /// Issues and related comments, assignees, labels, and milestones. + /// The level of permission to grant the access token for managing repository environments. + /// + public StringEnum? Environments { get; private set; } + + /// + /// The level of permission to grant the access token for issues and related comments, assignees, labels, and milestones. /// public StringEnum? Issues { get; private set; } /// - /// Pages - /// Retrieve Pages statuses, configuration, and builds, as well as create new builds. + /// The level of permission to grant the access token to search repositories, list collaborators, and access repository metadata. + /// + public StringEnum? Metadata { get; private set; } + + /// + /// The level of permission to grant the access token for packages published to GitHub Packages. + /// + public StringEnum? Packages { get; private set; } + + /// + /// The level of permission to grant the access token to retrieve Pages statuses, configuration, and builds, as well as create new builds. /// public StringEnum? Pages { get; private set; } /// - /// Pull requests - /// Pull requests and related comments, assignees, labels, milestones, and merges. + /// The level of permission to grant the access token for pull requests and related comments, assignees, labels, milestones, and merges. /// public StringEnum? PullRequests { get; private set; } /// - /// Repository contents - /// Repository contents, commits, branches, downloads, releases, and merges. + /// The level of permission to grant the access token to view and manage announcement banners for a repository. /// - public StringEnum? Contents { get; private set; } + public StringEnum? RepositoryAnnouncementBanners { get; private set; } /// - /// Single file - /// Manage just a single file. + /// The level of permission to grant the access token to manage the post-receive hooks for a repository. /// - public StringEnum? SingleFile { get; private set; } + public StringEnum? RepositoryHooks { get; private set; } /// - /// Repository projects - /// Manage repository projects, columns, and cards. + /// The level of permission to grant the access token to manage repository projects, columns, and cards. /// public StringEnum? RepositoryProjects { get; private set; } /// - /// Checks - /// Detailed information about CI checks + /// The level of permission to grant the access token to view and manage secret scanning alerts. /// - public StringEnum? Checks { get; private set; } + public StringEnum? SecretScanningAlerts { get; private set; } /// - /// Organization members (only applicable when installed for an Organization ) - /// Organization members and teams. + /// The level of permission to grant the access token to manage repository secrets. + /// + public StringEnum? Secrets { get; private set; } + + /// + /// The level of permission to grant the access token to view and manage security events like code scanning alerts. + /// + public StringEnum? SecurityEvents { get; private set; } + + /// + /// The level of permission to grant the access token to manage just a single file. + /// + public StringEnum? SingleFile { get; private set; } + + /// + /// The level of permission to grant the access token for commit statuses. + /// + public StringEnum? Statuses { get; private set; } + + /// + /// The level of permission to grant the access token to manage Dependabot alerts. + /// + public StringEnum? VulnerabilityAlerts { get; private set; } + + /// + /// The level of permission to grant the access token to update GitHub Actions workflow files. + /// + public StringEnum? Workflows { get; private set; } + + /// + /// The level of permission to grant the access token for organization teams and members. /// public StringEnum? Members { get; private set; } /// - /// Organization projects (only applicable when installed for an Organization ) - /// Manage organization projects, columns, and cards. + /// The level of permission to grant the access token to manage access to an organization. + /// + public StringEnum? OrganizationAdministration { get; private set; } + + /// + /// The level of permission to grant the access token for custom roles management. This property is in beta and is subject to change. + /// + public StringEnum? OrganizationCustomRoles { get; private set; } + + /// + /// The level of permission to grant the access token to view and manage announcement banners for an organization. + /// + public StringEnum? OrganizationAnnouncementBanners { get; private set; } + + /// + /// The level of permission to grant the access token to manage the post-receive hooks for an organization. + /// + public StringEnum? OrganizationHooks { get; private set; } + + /// + /// The level of permission to grant the access token for viewing an organization's plan. + /// + public StringEnum? OrganizationPlan { get; private set; } + + /// + /// The level of permission to grant the access token to manage organization projects and projects beta (where available). /// public StringEnum? OrganizationProjects { get; private set; } /// - /// Team discussions (only applicable when installed for an Organization ) - /// Team discussions. + /// The level of permission to grant the access token for organization packages published to GitHub Packages. + /// + public StringEnum? OrganizationPackages { get; private set; } + + /// + /// The level of permission to grant the access token to manage organization secrets. + /// + public StringEnum? OrganizationSecrets { get; private set; } + + /// + /// The level of permission to grant the access token to view and manage GitHub Actions self-hosted runners available to an organization. + /// + public StringEnum? OrganizationSelfHostedRunners { get; private set; } + + /// + /// The level of permission to grant the access token to view and manage users blocked by the organization. + /// + public StringEnum? OrganizationUserBlocking { get; private set; } + + /// + /// The level of permission to grant the access token to manage team discussions and related comments. /// public StringEnum? TeamDiscussions { get; private set; } internal string DebuggerDisplay { - get { return string.Format(CultureInfo.InvariantCulture, "Metadata: {0}, Contents: {1}, Issues: {2}, Single File: {3}", Metadata, Contents, Issues, SingleFile); } + get => $"Actions: {Actions}, Administration: {Administration}, Checks: {Checks}, Contents: {Contents}, Deployments: {Deployments}, Environments: {Environments}, Issues: {Issues}, Metadata: {Metadata}, Packages: {Packages}, Pages: {Pages}, PullRequests: {PullRequests}, RepositoryAnnouncementBanners: {RepositoryAnnouncementBanners}, RepositoryHooks: {RepositoryHooks}, RepositoryProjects: {RepositoryProjects}, SecretScanningAlerts: {SecretScanningAlerts}, Secrets: {Secrets}, SecurityEvents: {SecurityEvents}, SingleFile: {SingleFile}, Statuses: {Statuses}, VulnerabilityAlerts: {VulnerabilityAlerts}, Workflows: {Workflows}, Members: {Members}, OrganizationAdministration: {OrganizationAdministration}, OrganizationCustomRoles: {OrganizationCustomRoles}, OrganizationAnnouncementBanners: {OrganizationAnnouncementBanners}, OrganizationHooks: {OrganizationHooks}, OrganizationPlan: {OrganizationPlan}, OrganizationProjects: {OrganizationProjects}, OrganizationPackages: {OrganizationPackages}, OrganizationSecrets: {OrganizationSecrets}, OrganizationSelfHostedRunners: {OrganizationSelfHostedRunners}, OrganizationUserBlocking: {OrganizationUserBlocking}, TeamDiscussions: {TeamDiscussions}"; } } diff --git a/Octokit/Models/Response/Meta.cs b/Octokit/Models/Response/Meta.cs index a5a8a644b4..97b630fed5 100644 --- a/Octokit/Models/Response/Meta.cs +++ b/Octokit/Models/Response/Meta.cs @@ -7,7 +7,7 @@ namespace Octokit { /// - /// Response from the /meta endpoint that provides information about GitHub.com or a GitHub Enterprise instance. + /// Response from the /meta endpoint that provides information about GitHub.com or a GitHub Enterprise instance. /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class Meta @@ -33,6 +33,7 @@ public Meta() /// 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 + /// The installed version of GitHub Enterprise Server public Meta( bool verifiablePasswordAuthentication, string gitHubServicesSha, @@ -44,7 +45,8 @@ public Meta( IReadOnlyList pages, IReadOnlyList importer, IReadOnlyList actions, - IReadOnlyList dependabot) + IReadOnlyList dependabot, + string installedVersion) { VerifiablePasswordAuthentication = verifiablePasswordAuthentication; #pragma warning disable CS0618 // Type or member is obsolete @@ -59,6 +61,7 @@ public Meta( Importer = importer; Actions = actions; Dependabot = dependabot; + InstalledVersion = installedVersion; } /// @@ -124,6 +127,11 @@ public Meta( /// public IReadOnlyList Dependabot { get; private set; } + /// + /// The installed version of GitHub Enterprise Server. + /// + public string InstalledVersion { get; private set; } + internal string DebuggerDisplay { get From 817dc1673df3edcd01426931a2ad3dbd6637163c Mon Sep 17 00:00:00 2001 From: Matisse Hack Date: Thu, 1 Dec 2022 15:42:43 -0800 Subject: [PATCH 2/2] Update test with actual value instead of null --- Octokit.Tests/Clients/MetaClientTests.cs | 2 +- Octokit.Tests/Clients/MiscellaneousClientTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests/Clients/MetaClientTests.cs b/Octokit.Tests/Clients/MetaClientTests.cs index 212066871e..f033b411d2 100644 --- a/Octokit.Tests/Clients/MetaClientTests.cs +++ b/Octokit.Tests/Clients/MetaClientTests.cs @@ -24,7 +24,7 @@ public async Task RequestsTheMetadataEndpoint() 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" }, - null + "3.7.0" ); diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index 5ddac79377..7a184d02da 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -157,7 +157,7 @@ public async Task RequestsTheMetadataEndpoint() 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" }, - null + "3.7.0" ); var apiConnection = Substitute.For();