From 65184486bb0428055a2257363cacb927c3976b3c Mon Sep 17 00:00:00 2001 From: notauserx Date: Mon, 23 Jan 2023 15:45:49 +0600 Subject: [PATCH 01/39] move enum and rename response class --- .../IObservableRepoCollaboratorsClient.cs | 4 ++-- .../Clients/ObservableRepoCollaboratorsClient.cs | 4 ++-- .../Clients/RepoCollaboratorsClientTests.cs | 4 ++-- Octokit/Clients/IRepoCollaboratorsClient.cs | 4 ++-- Octokit/Clients/RepoCollaboratorsClient.cs | 8 ++++---- Octokit/Models/Request/Permission.cs | 12 ++++++++++++ .../Models/Response/CollaboratorPermission.cs | 6 +++--- Octokit/Models/Response/PermissionLevel.cs | 16 ---------------- 8 files changed, 27 insertions(+), 31 deletions(-) delete mode 100644 Octokit/Models/Response/PermissionLevel.cs diff --git a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs index 6dc5561174..2cfcdd1152 100644 --- a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs @@ -136,7 +136,7 @@ public interface IObservableRepoCollaboratorsClient /// The name of the repository /// Username of the collaborator to check permission for /// Thrown when a general API error occurs. - IObservable ReviewPermission(string owner, string name, string user); + IObservable ReviewPermission(string owner, string name, string user); /// /// Review a user's permission level in a repository @@ -147,7 +147,7 @@ public interface IObservableRepoCollaboratorsClient /// The id of the repository /// Username of the collaborator to check permission for /// Thrown when a general API error occurs. - IObservable ReviewPermission(long repositoryId, string user); + IObservable ReviewPermission(long repositoryId, string user); /// /// Adds a new collaborator to the repository. diff --git a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs index 38f8f710e3..b1bd49a9e3 100644 --- a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs @@ -212,7 +212,7 @@ public IObservable IsCollaborator(long repositoryId, string user) /// The name of the repository /// Username of the collaborator to check permission for /// Thrown when a general API error occurs. - public IObservable ReviewPermission(string owner, string name, string user) + public IObservable ReviewPermission(string owner, string name, string user) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -230,7 +230,7 @@ public IObservable ReviewPermission(string owner, string /// The id of the repository /// Username of the collaborator to check permission for /// Thrown when a general API error occurs. - public IObservable ReviewPermission(long repositoryId, string user) + public IObservable ReviewPermission(long repositoryId, string user) { Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); diff --git a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs index 7e5f0d9084..7346217d14 100644 --- a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs +++ b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs @@ -301,7 +301,7 @@ public void RequestsCorrectUrl() var client = new RepoCollaboratorsClient(connection); client.ReviewPermission("owner", "test", "user1"); - connection.Received().Get( + connection.Received().Get( Arg.Is(u => u.ToString() == "repos/owner/test/collaborators/user1/permission"), Arg.Any>()); } @@ -313,7 +313,7 @@ public void RequestsCorrectUrlWithRepositoryId() var client = new RepoCollaboratorsClient(connection); client.ReviewPermission(1L, "user1"); - connection.Received().Get( + connection.Received().Get( Arg.Is(u => u.ToString() == "repositories/1/collaborators/user1/permission"), Arg.Any>()); } diff --git a/Octokit/Clients/IRepoCollaboratorsClient.cs b/Octokit/Clients/IRepoCollaboratorsClient.cs index 1cc0593598..db3b0a4619 100644 --- a/Octokit/Clients/IRepoCollaboratorsClient.cs +++ b/Octokit/Clients/IRepoCollaboratorsClient.cs @@ -136,7 +136,7 @@ public interface IRepoCollaboratorsClient /// The name of the repository /// Username of the collaborator to check permission for /// Thrown when a general API error occurs. - Task ReviewPermission(string owner, string name, string user); + Task ReviewPermission(string owner, string name, string user); /// /// Review a user's permission level in a repository @@ -147,7 +147,7 @@ public interface IRepoCollaboratorsClient /// The id of the repository /// Username of the collaborator to check permission for /// Thrown when a general API error occurs. - Task ReviewPermission(long repositoryId, string user); + Task ReviewPermission(long repositoryId, string user); /// /// Adds a new collaborator to the repository. diff --git a/Octokit/Clients/RepoCollaboratorsClient.cs b/Octokit/Clients/RepoCollaboratorsClient.cs index 499ba4a23d..6addd21532 100644 --- a/Octokit/Clients/RepoCollaboratorsClient.cs +++ b/Octokit/Clients/RepoCollaboratorsClient.cs @@ -232,14 +232,14 @@ public async Task IsCollaborator(long repositoryId, string user) /// Username of the collaborator to check permission for /// Thrown when a general API error occurs. [ManualRoute("GET", "/repos/{owner}/{repo}/collaborators/{username}/permission")] - public Task ReviewPermission(string owner, string name, string user) + public Task ReviewPermission(string owner, string name, string user) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); return ApiConnection - .Get(ApiUrls.RepoCollaboratorPermission(owner, name, user), null); + .Get(ApiUrls.RepoCollaboratorPermission(owner, name, user), null); } /// @@ -252,12 +252,12 @@ public Task ReviewPermission(string owner, string name, /// Username of the collaborator to check permission for /// Thrown when a general API error occurs. [ManualRoute("GET", "/repository/{id}/collaborators/{username}/permission")] - public Task ReviewPermission(long repositoryId, string user) + public Task ReviewPermission(long repositoryId, string user) { Ensure.ArgumentNotNullOrEmptyString(user, nameof(user)); return ApiConnection - .Get(ApiUrls.RepoCollaboratorPermission(repositoryId, user), null); + .Get(ApiUrls.RepoCollaboratorPermission(repositoryId, user), null); } /// diff --git a/Octokit/Models/Request/Permission.cs b/Octokit/Models/Request/Permission.cs index f3f94e003b..e5da62da55 100644 --- a/Octokit/Models/Request/Permission.cs +++ b/Octokit/Models/Request/Permission.cs @@ -63,6 +63,18 @@ public enum TeamPermission Push } + public enum PermissionLevel + { + [Parameter(Value = "admin")] + Admin, + [Parameter(Value = "write")] + Write, + [Parameter(Value = "read")] + Read, + [Parameter(Value = "none")] + None + } + /// /// Object for team repository permissions /// diff --git a/Octokit/Models/Response/CollaboratorPermission.cs b/Octokit/Models/Response/CollaboratorPermission.cs index 7e2ed0a577..dafecd2070 100644 --- a/Octokit/Models/Response/CollaboratorPermission.cs +++ b/Octokit/Models/Response/CollaboratorPermission.cs @@ -3,11 +3,11 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CollaboratorPermission + public class CollaboratorPermissionResponse { - public CollaboratorPermission() { } + public CollaboratorPermissionResponse() { } - public CollaboratorPermission(PermissionLevel permission, User user) + public CollaboratorPermissionResponse(PermissionLevel permission, User user) { Permission = permission; User = user; diff --git a/Octokit/Models/Response/PermissionLevel.cs b/Octokit/Models/Response/PermissionLevel.cs deleted file mode 100644 index b857a2b7bd..0000000000 --- a/Octokit/Models/Response/PermissionLevel.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Octokit.Internal; - -namespace Octokit -{ - public enum PermissionLevel - { - [Parameter(Value = "admin")] - Admin, - [Parameter(Value = "write")] - Write, - [Parameter(Value = "read")] - Read, - [Parameter(Value = "none")] - None - } -} From 2f626dbf3be4209245eb51a5348c0dd1aeced5b4 Mon Sep 17 00:00:00 2001 From: notauserx Date: Mon, 23 Jan 2023 16:19:38 +0600 Subject: [PATCH 02/39] move InvitationPermissionType to Permission.cs --- Octokit/Models/Request/Permission.cs | 10 ++++++++++ Octokit/Models/Response/RepositoryInvitation.cs | 13 ------------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Octokit/Models/Request/Permission.cs b/Octokit/Models/Request/Permission.cs index e5da62da55..7201e71b33 100644 --- a/Octokit/Models/Request/Permission.cs +++ b/Octokit/Models/Request/Permission.cs @@ -63,6 +63,16 @@ public enum TeamPermission Push } + public enum InvitationPermissionType + { + [Parameter(Value = "read")] + Read, + [Parameter(Value = "write")] + Write, + [Parameter(Value = "admin")] + Admin + } + public enum PermissionLevel { [Parameter(Value = "admin")] diff --git a/Octokit/Models/Response/RepositoryInvitation.cs b/Octokit/Models/Response/RepositoryInvitation.cs index 98b027e553..9e6ba02382 100644 --- a/Octokit/Models/Response/RepositoryInvitation.cs +++ b/Octokit/Models/Response/RepositoryInvitation.cs @@ -1,22 +1,9 @@ using System; using System.Diagnostics; using System.Globalization; -using Octokit.Internal; namespace Octokit { - public enum InvitationPermissionType - { - [Parameter(Value = "read")] - Read, - - [Parameter(Value = "write")] - Write, - - [Parameter(Value = "admin")] - Admin - } - [DebuggerDisplay("{DebuggerDisplay,nq}")] public class RepositoryInvitation { From 0c4a129e773c3e7c27906af0cbca8cf531d452c7 Mon Sep 17 00:00:00 2001 From: notauserx Date: Mon, 23 Jan 2023 16:21:58 +0600 Subject: [PATCH 03/39] rename PermissionLevel enum --- .../Clients/RepositoryCollaboratorClientTests.cs | 16 ++++++++-------- ...bservableRepositoryCollaboratorClientTests.cs | 16 ++++++++-------- Octokit/Models/Request/Permission.cs | 2 +- .../Models/Response/CollaboratorPermission.cs | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs index 0859a81431..2e83f08ae8 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs @@ -275,7 +275,7 @@ public async Task ReturnsReadPermissionForNonCollaborator() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - Assert.Equal(PermissionLevel.Read, permission.Permission); + Assert.Equal(CollaboratorPermission.Read, permission.Permission); } } @@ -291,7 +291,7 @@ public async Task ReturnsReadPermissionForNonCollaboratorWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); - Assert.Equal(PermissionLevel.Read, permission.Permission); + Assert.Equal(CollaboratorPermission.Read, permission.Permission); } } @@ -310,7 +310,7 @@ public async Task ReturnsWritePermissionForCollaborator() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - Assert.Equal(PermissionLevel.Write, permission.Permission); + Assert.Equal(CollaboratorPermission.Write, permission.Permission); } } @@ -329,7 +329,7 @@ public async Task ReturnsWritePermissionForCollaboratorWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); - Assert.Equal(PermissionLevel.Write, permission.Permission); + Assert.Equal(CollaboratorPermission.Write, permission.Permission); } } @@ -345,7 +345,7 @@ public async Task ReturnsAdminPermissionForOwner() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner); - Assert.Equal(PermissionLevel.Admin, permission.Permission); + Assert.Equal(CollaboratorPermission.Admin, permission.Permission); } } @@ -361,7 +361,7 @@ public async Task ReturnsAdminPermissionForOwnerWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, context.RepositoryOwner); - Assert.Equal(PermissionLevel.Admin, permission.Permission); + Assert.Equal(CollaboratorPermission.Admin, permission.Permission); } } @@ -382,7 +382,7 @@ public async Task ReturnsNonePermissionForPrivateRepository() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - Assert.Equal(PermissionLevel.None, permission.Permission); + Assert.Equal(CollaboratorPermission.None, permission.Permission); } } @@ -403,7 +403,7 @@ public async Task ReturnsNonePermissionForPrivateRepositoryWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); - Assert.Equal(PermissionLevel.None, permission.Permission); + Assert.Equal(CollaboratorPermission.None, permission.Permission); } } } diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs index 363e7465a8..c3208ad8fe 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs @@ -153,7 +153,7 @@ public async Task ReturnsReadPermissionForNonCollaborator() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - Assert.Equal(PermissionLevel.Read, permission.Permission); + Assert.Equal(CollaboratorPermission.Read, permission.Permission); } } @@ -169,7 +169,7 @@ public async Task ReturnsReadPermissionForNonCollaboratorWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); - Assert.Equal(PermissionLevel.Read, permission.Permission); + Assert.Equal(CollaboratorPermission.Read, permission.Permission); } } @@ -188,7 +188,7 @@ public async Task ReturnsWritePermissionForCollaborator() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - Assert.Equal(PermissionLevel.Write, permission.Permission); + Assert.Equal(CollaboratorPermission.Write, permission.Permission); } } @@ -207,7 +207,7 @@ public async Task ReturnsWritePermissionForCollaboratorWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); - Assert.Equal(PermissionLevel.Write, permission.Permission); + Assert.Equal(CollaboratorPermission.Write, permission.Permission); } } @@ -223,7 +223,7 @@ public async Task ReturnsAdminPermissionForOwner() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner); - Assert.Equal(PermissionLevel.Admin, permission.Permission); + Assert.Equal(CollaboratorPermission.Admin, permission.Permission); } } @@ -239,7 +239,7 @@ public async Task ReturnsAdminPermissionForOwnerWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, context.RepositoryOwner); - Assert.Equal(PermissionLevel.Admin, permission.Permission); + Assert.Equal(CollaboratorPermission.Admin, permission.Permission); } } @@ -260,7 +260,7 @@ public async Task ReturnsNonePermissionForPrivateRepository() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - Assert.Equal(PermissionLevel.None, permission.Permission); + Assert.Equal(CollaboratorPermission.None, permission.Permission); } } @@ -281,7 +281,7 @@ public async Task ReturnsNonePermissionForPrivateRepositoryWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); - Assert.Equal(PermissionLevel.None, permission.Permission); + Assert.Equal(CollaboratorPermission.None, permission.Permission); } } } diff --git a/Octokit/Models/Request/Permission.cs b/Octokit/Models/Request/Permission.cs index 7201e71b33..c44c8d05e0 100644 --- a/Octokit/Models/Request/Permission.cs +++ b/Octokit/Models/Request/Permission.cs @@ -73,7 +73,7 @@ public enum InvitationPermissionType Admin } - public enum PermissionLevel + public enum CollaboratorPermission { [Parameter(Value = "admin")] Admin, diff --git a/Octokit/Models/Response/CollaboratorPermission.cs b/Octokit/Models/Response/CollaboratorPermission.cs index dafecd2070..34e806e265 100644 --- a/Octokit/Models/Response/CollaboratorPermission.cs +++ b/Octokit/Models/Response/CollaboratorPermission.cs @@ -7,13 +7,13 @@ public class CollaboratorPermissionResponse { public CollaboratorPermissionResponse() { } - public CollaboratorPermissionResponse(PermissionLevel permission, User user) + public CollaboratorPermissionResponse(CollaboratorPermission permission, User user) { Permission = permission; User = user; } - public StringEnum Permission { get; private set; } + public StringEnum Permission { get; private set; } public User User { get; private set; } internal string DebuggerDisplay => $"User: {User.Id} Permission: {Permission}"; From 89b4c8aacc1ec6379da0474600cc39658281dd7e Mon Sep 17 00:00:00 2001 From: notauserx Date: Mon, 23 Jan 2023 16:24:11 +0600 Subject: [PATCH 04/39] mark failing tests --- .../Clients/RepositoryCollaboratorClientTests.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs index 2e83f08ae8..ffe707c580 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs @@ -295,6 +295,7 @@ public async Task ReturnsReadPermissionForNonCollaboratorWithRepositoryId() } } + // TODO :: This test is failing in current main, should I remove this test? [IntegrationTest] public async Task ReturnsWritePermissionForCollaborator() { @@ -314,6 +315,8 @@ public async Task ReturnsWritePermissionForCollaborator() } } + + // TODO :: This test is failing in current main, should I remove this test? [IntegrationTest] public async Task ReturnsWritePermissionForCollaboratorWithRepositoryId() { From 1b6d39d7373bb04fb49ecfd8419252ba60460686 Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 09:08:17 +0600 Subject: [PATCH 05/39] update summary for collaborators clients --- Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs | 2 +- Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs | 2 +- Octokit/Clients/IRepoCollaboratorsClient.cs | 2 +- Octokit/Clients/RepoCollaboratorsClient.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs index 2cfcdd1152..a42c320cf1 100644 --- a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs @@ -4,7 +4,7 @@ namespace Octokit.Reactive { /// - /// A client for GitHub's Collaborators on a Repository. + /// A client for GitHub's Collaborators API. /// /// /// See the Collaborators API documentation for more details. diff --git a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs index b1bd49a9e3..563bd90db2 100644 --- a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs @@ -6,7 +6,7 @@ namespace Octokit.Reactive { /// - /// A client for GitHub's Collaborators on a Repository. + /// A client for GitHub's Collaborators API. /// /// /// See the Collaborators API documentation for more details. diff --git a/Octokit/Clients/IRepoCollaboratorsClient.cs b/Octokit/Clients/IRepoCollaboratorsClient.cs index db3b0a4619..b0b066eee8 100644 --- a/Octokit/Clients/IRepoCollaboratorsClient.cs +++ b/Octokit/Clients/IRepoCollaboratorsClient.cs @@ -4,7 +4,7 @@ namespace Octokit { /// - /// A client for GitHub's Collaborators on a Repository. + /// A client for GitHub's Collaborators API. /// /// /// See the Collaborators API documentation for more details. diff --git a/Octokit/Clients/RepoCollaboratorsClient.cs b/Octokit/Clients/RepoCollaboratorsClient.cs index 6addd21532..bdf8a2cf17 100644 --- a/Octokit/Clients/RepoCollaboratorsClient.cs +++ b/Octokit/Clients/RepoCollaboratorsClient.cs @@ -4,7 +4,7 @@ namespace Octokit { /// - /// A client for GitHub's Collaborators on a Repository. + /// A client for GitHub's Collaborators API. /// /// /// See the Collaborators API documentation for more details. From 60e9d305807c437757cb40d383d8b98105307a6b Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 09:10:17 +0600 Subject: [PATCH 06/39] update api link --- Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs | 2 +- Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs | 2 +- Octokit/Clients/IRepoCollaboratorsClient.cs | 2 +- Octokit/Clients/RepoCollaboratorsClient.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs index a42c320cf1..18c2f8b06d 100644 --- a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs @@ -7,7 +7,7 @@ namespace Octokit.Reactive /// A client for GitHub's Collaborators API. /// /// - /// See the Collaborators API documentation for more details. + /// See the Collaborators API documentation for more details. /// public interface IObservableRepoCollaboratorsClient { diff --git a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs index 563bd90db2..d9c7cd78ad 100644 --- a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs @@ -9,7 +9,7 @@ namespace Octokit.Reactive /// A client for GitHub's Collaborators API. /// /// - /// See the Collaborators API documentation for more details. + /// See the Collaborators API documentation for more details. /// public class ObservableRepoCollaboratorsClient : IObservableRepoCollaboratorsClient { diff --git a/Octokit/Clients/IRepoCollaboratorsClient.cs b/Octokit/Clients/IRepoCollaboratorsClient.cs index b0b066eee8..280473f2bd 100644 --- a/Octokit/Clients/IRepoCollaboratorsClient.cs +++ b/Octokit/Clients/IRepoCollaboratorsClient.cs @@ -7,7 +7,7 @@ namespace Octokit /// A client for GitHub's Collaborators API. /// /// - /// See the Collaborators API documentation for more details. + /// See the Collaborators API documentation for more details. /// public interface IRepoCollaboratorsClient { diff --git a/Octokit/Clients/RepoCollaboratorsClient.cs b/Octokit/Clients/RepoCollaboratorsClient.cs index bdf8a2cf17..09433023c4 100644 --- a/Octokit/Clients/RepoCollaboratorsClient.cs +++ b/Octokit/Clients/RepoCollaboratorsClient.cs @@ -7,7 +7,7 @@ namespace Octokit /// A client for GitHub's Collaborators API. /// /// - /// See the Collaborators API documentation for more details. + /// See the Collaborators API documentation for more details. /// public class RepoCollaboratorsClient : ApiClient, IRepoCollaboratorsClient { From 7039f1e2f74268e3af289e3aff7f95b7dbe243db Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 09:55:33 +0600 Subject: [PATCH 07/39] add collaborator model --- Octokit/Models/Request/Permission.cs | 36 ++++++++++ Octokit/Models/Response/Collaborator.cs | 95 +++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 Octokit/Models/Response/Collaborator.cs diff --git a/Octokit/Models/Request/Permission.cs b/Octokit/Models/Request/Permission.cs index c44c8d05e0..456b23af58 100644 --- a/Octokit/Models/Request/Permission.cs +++ b/Octokit/Models/Request/Permission.cs @@ -145,4 +145,40 @@ internal string DebuggerDisplay } } } + + /// + /// Object for collaborator permissions + /// + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class CollaboratorPermissions + { + public CollaboratorPermissions() { } + public CollaboratorPermissions(bool pull, bool? triage, bool push, bool? maintain, bool admin) + { + Pull = pull; + Triage = triage; + Push = push; + Maintain = maintain; + Admin = admin; + } + + public bool Pull { get; private set; } + + public bool? Triage { get; private set; } + + public bool Push { get; private set; } + + public bool? Maintain { get; private set; } + + public bool Admin { get; private set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, + $"Permissions: Pull: {Pull}, Triage: {Triage}, Push: {Push}, Maintain: {Maintain}, Admin: {Admin}"); + } + } + } } diff --git a/Octokit/Models/Response/Collaborator.cs b/Octokit/Models/Response/Collaborator.cs new file mode 100644 index 0000000000..8e6c152718 --- /dev/null +++ b/Octokit/Models/Response/Collaborator.cs @@ -0,0 +1,95 @@ +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class Collaborator + { + public Collaborator() { } + + public Collaborator(string login, int id, string email, string name, string nodeId, string avatarUrl, string gravatarUrl, string url, string htmlUrl, string followersUrl, string followingUrl, string gistsUrl, string type, string starredUrl, string subscriptionsUrl, string organizationsUrl, string reposUrl, string eventsUrl, string receivedEventsUrl, bool siteAdmin, CollaboratorPermission permissions, string roleName) + { + Login = login; + Id = id; + Email = email; + Name = name; + NodeId = nodeId; + AvatarUrl = avatarUrl; + GravatarUrl = gravatarUrl; + Url = url; + HtmlUrl = htmlUrl; + FollowersUrl = followersUrl; + FollowingUrl = followingUrl; + GistsUrl = gistsUrl; + StarredUrl = starredUrl; + SubscriptionsUrl = subscriptionsUrl; + OrganizationsUrl = organizationsUrl; + ReposUrl = reposUrl; + EventsUrl = eventsUrl; + ReceivedEventsUrl = receivedEventsUrl; + Type = type; + SiteAdmin = siteAdmin; + Permissions = permissions; + RoleName = roleName; + } + + public string Login { get; protected set; } + + public int Id { get; protected set; } + + public string Email { get; protected set; } + + public string Name { get; protected set; } + + /// + /// GraphQL Node Id + /// + public string NodeId { get; protected set; } + + public string AvatarUrl { get; protected set; } + + public string GravatarUrl { get; protected set; } + + public string Url { get; protected set; } + + public string HtmlUrl { get; protected set; } + + public string FollowersUrl { get; protected set; } + + public string FollowingUrl { get; protected set; } + + public string GistsUrl { get; protected set; } + + public string StarredUrl { get; protected set; } + + public string SubscriptionsUrl { get; protected set; } + + public string OrganizationsUrl { get; protected set; } + + public string ReposUrl { get; protected set; } + + public string EventsUrl { get; protected set; } + + public string ReceivedEventsUrl { get; protected set; } + + [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "This is what is returned from the API")] + public string Type { get; protected set; } + + public bool SiteAdmin { get; protected set; } + + public CollaboratorPermission Permissions { get; protected set; } + + public string RoleName { get; protected set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, + "Author: Id: {0} Login: {1}", Id, Login); + } + } + } +} \ No newline at end of file From 4bea499a5308368c695a83a23563b76446f2e2be Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 11:38:24 +0600 Subject: [PATCH 08/39] update models --- .../RepositoryCollaboratorClientTests.cs | 17 ++++++++-------- ...rvableRepositoryCollaboratorClientTests.cs | 18 +++++++++-------- Octokit/Models/Request/Permission.cs | 9 ++++++++- Octokit/Models/Response/Collaborator.cs | 2 +- .../Models/Response/CollaboratorPermission.cs | 17 +++++++++++----- .../Models/Response/RepositoryInvitation.cs | 20 ++++++++++++++++++- 6 files changed, 59 insertions(+), 24 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs index ffe707c580..247ac81dc0 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs @@ -20,6 +20,7 @@ public async Task ReturnsAllCollaborators() var fixture = github.Repository.Collaborator; // add a collaborator + // this sends a repository invitation, the collaborator still has to accept the invitation. await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName); @@ -275,7 +276,7 @@ public async Task ReturnsReadPermissionForNonCollaborator() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - Assert.Equal(CollaboratorPermission.Read, permission.Permission); + Assert.Equal("read", permission.Permission); } } @@ -291,7 +292,7 @@ public async Task ReturnsReadPermissionForNonCollaboratorWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); - Assert.Equal(CollaboratorPermission.Read, permission.Permission); + Assert.Equal("read", permission.Permission); } } @@ -311,7 +312,7 @@ public async Task ReturnsWritePermissionForCollaborator() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - Assert.Equal(CollaboratorPermission.Write, permission.Permission); + Assert.Equal("write", permission.Permission); } } @@ -332,7 +333,7 @@ public async Task ReturnsWritePermissionForCollaboratorWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); - Assert.Equal(CollaboratorPermission.Write, permission.Permission); + Assert.Equal("write", permission.Permission); } } @@ -348,7 +349,7 @@ public async Task ReturnsAdminPermissionForOwner() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner); - Assert.Equal(CollaboratorPermission.Admin, permission.Permission); + Assert.Equal("admin", permission.Permission); } } @@ -364,7 +365,7 @@ public async Task ReturnsAdminPermissionForOwnerWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, context.RepositoryOwner); - Assert.Equal(CollaboratorPermission.Admin, permission.Permission); + Assert.Equal("admin", permission.Permission); } } @@ -385,7 +386,7 @@ public async Task ReturnsNonePermissionForPrivateRepository() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - Assert.Equal(CollaboratorPermission.None, permission.Permission); + Assert.Equal("none", permission.Permission); } } @@ -406,7 +407,7 @@ public async Task ReturnsNonePermissionForPrivateRepositoryWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); - Assert.Equal(CollaboratorPermission.None, permission.Permission); + Assert.Equal("none", permission.Permission); } } } diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs index c3208ad8fe..4d3a349f1b 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs @@ -22,10 +22,12 @@ public async Task ReturnsAllCollaborators() var fixture = new ObservableRepoCollaboratorsClient(github); // add a collaborator + // this sends a repository invitation await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName).ToList(); Assert.NotNull(collaborators); + // this assert fails, added collaborator has to accept the invitation. Assert.Equal(2, collaborators.Count); Assert.NotNull(collaborators[0].Permissions); Assert.NotNull(collaborators[1].Permissions); @@ -153,7 +155,7 @@ public async Task ReturnsReadPermissionForNonCollaborator() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - Assert.Equal(CollaboratorPermission.Read, permission.Permission); + Assert.Equal("read", permission.Permission); } } @@ -169,7 +171,7 @@ public async Task ReturnsReadPermissionForNonCollaboratorWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); - Assert.Equal(CollaboratorPermission.Read, permission.Permission); + Assert.Equal("read", permission.Permission); } } @@ -188,7 +190,7 @@ public async Task ReturnsWritePermissionForCollaborator() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - Assert.Equal(CollaboratorPermission.Write, permission.Permission); + Assert.Equal("write", permission.Permission); } } @@ -207,7 +209,7 @@ public async Task ReturnsWritePermissionForCollaboratorWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); - Assert.Equal(CollaboratorPermission.Write, permission.Permission); + Assert.Equal("write", permission.Permission); } } @@ -223,7 +225,7 @@ public async Task ReturnsAdminPermissionForOwner() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner); - Assert.Equal(CollaboratorPermission.Admin, permission.Permission); + Assert.Equal("admin", permission.Permission); } } @@ -239,7 +241,7 @@ public async Task ReturnsAdminPermissionForOwnerWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, context.RepositoryOwner); - Assert.Equal(CollaboratorPermission.Admin, permission.Permission); + Assert.Equal("admin", permission.Permission); } } @@ -260,7 +262,7 @@ public async Task ReturnsNonePermissionForPrivateRepository() var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - Assert.Equal(CollaboratorPermission.None, permission.Permission); + Assert.Equal("none", permission.Permission); } } @@ -281,7 +283,7 @@ public async Task ReturnsNonePermissionForPrivateRepositoryWithRepositoryId() var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); - Assert.Equal(CollaboratorPermission.None, permission.Permission); + Assert.Equal("none", permission.Permission); } } } diff --git a/Octokit/Models/Request/Permission.cs b/Octokit/Models/Request/Permission.cs index 456b23af58..c0643fd663 100644 --- a/Octokit/Models/Request/Permission.cs +++ b/Octokit/Models/Request/Permission.cs @@ -63,6 +63,9 @@ public enum TeamPermission Push } + /// + /// The permission associated with the invitation for a collaborator in a repository + /// public enum InvitationPermissionType { [Parameter(Value = "read")] @@ -70,7 +73,11 @@ public enum InvitationPermissionType [Parameter(Value = "write")] Write, [Parameter(Value = "admin")] - Admin + Admin, + [Parameter(Value = "triage")] + Triage, + [Parameter(Value = "maintain")] + Maintain } public enum CollaboratorPermission diff --git a/Octokit/Models/Response/Collaborator.cs b/Octokit/Models/Response/Collaborator.cs index 8e6c152718..4ba0786fc8 100644 --- a/Octokit/Models/Response/Collaborator.cs +++ b/Octokit/Models/Response/Collaborator.cs @@ -79,7 +79,7 @@ public Collaborator(string login, int id, string email, string name, string node public bool SiteAdmin { get; protected set; } - public CollaboratorPermission Permissions { get; protected set; } + public StringEnum Permissions { get; protected set; } public string RoleName { get; protected set; } diff --git a/Octokit/Models/Response/CollaboratorPermission.cs b/Octokit/Models/Response/CollaboratorPermission.cs index 34e806e265..7dd8aa8b9e 100644 --- a/Octokit/Models/Response/CollaboratorPermission.cs +++ b/Octokit/Models/Response/CollaboratorPermission.cs @@ -2,20 +2,27 @@ namespace Octokit { + /// + /// Based on "#/components/schemas/repository-collaborator-permission: + /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class CollaboratorPermissionResponse { public CollaboratorPermissionResponse() { } - public CollaboratorPermissionResponse(CollaboratorPermission permission, User user) + public CollaboratorPermissionResponse(string permission, string roleName, Collaborator collaborator) { Permission = permission; - User = user; + RoleName = roleName; + Collaborator = collaborator; } - public StringEnum Permission { get; private set; } - public User User { get; private set; } + public string Permission { get; private set; } - internal string DebuggerDisplay => $"User: {User.Id} Permission: {Permission}"; + public string RoleName { get; private set; } + + public Collaborator Collaborator { get; private set; } + + internal string DebuggerDisplay => $"Collaborator: {Collaborator.Id} Permission: {Permission} RoleName: {RoleName}"; } } diff --git a/Octokit/Models/Response/RepositoryInvitation.cs b/Octokit/Models/Response/RepositoryInvitation.cs index 9e6ba02382..2a9ed22fdf 100644 --- a/Octokit/Models/Response/RepositoryInvitation.cs +++ b/Octokit/Models/Response/RepositoryInvitation.cs @@ -4,12 +4,15 @@ namespace Octokit { + /// + /// Repository invitations let you manage who you collaborate with. + /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class RepositoryInvitation { public RepositoryInvitation() { } - public RepositoryInvitation(int id, string nodeId, Repository repository, User invitee, User inviter, InvitationPermissionType permissions, DateTimeOffset createdAt, string url, string htmlUrl) + public RepositoryInvitation(int id, string nodeId, Repository repository, User invitee, User inviter, InvitationPermissionType permissions, DateTimeOffset createdAt, bool expired, string url, string htmlUrl) { Id = id; NodeId = nodeId; @@ -18,10 +21,14 @@ public RepositoryInvitation(int id, string nodeId, Repository repository, User i Inviter = inviter; Permissions = permissions; CreatedAt = createdAt; + Expired = expired; Url = url; HtmlUrl = htmlUrl; } + /// + /// Unique identifier of the repository invitation. + /// public int Id { get; private set; } /// @@ -35,10 +42,21 @@ public RepositoryInvitation(int id, string nodeId, Repository repository, User i public User Inviter { get; private set; } + /// + /// The permission associated with the invitation. + /// public StringEnum Permissions { get; private set; } public DateTimeOffset CreatedAt { get; private set; } + /// + /// Whether or not the invitation has expired + /// + public bool Expired { get; private set; } + + /// + /// URL for the repository invitation + /// public string Url { get; private set; } public string HtmlUrl { get; private set; } From 4c395d94be9ca6b975ae40b48ecc3eca68043e96 Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 11:45:56 +0600 Subject: [PATCH 09/39] move permissions to common folder --- Octokit/Models/{Request => Common}/Permission.cs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Octokit/Models/{Request => Common}/Permission.cs (100%) diff --git a/Octokit/Models/Request/Permission.cs b/Octokit/Models/Common/Permission.cs similarity index 100% rename from Octokit/Models/Request/Permission.cs rename to Octokit/Models/Common/Permission.cs From 57f7e40c8abde3ae4f23067467dbe561e85f9794 Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 12:44:18 +0600 Subject: [PATCH 10/39] fix debugger display --- Octokit/Models/Response/Collaborator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Response/Collaborator.cs b/Octokit/Models/Response/Collaborator.cs index 4ba0786fc8..772dc25788 100644 --- a/Octokit/Models/Response/Collaborator.cs +++ b/Octokit/Models/Response/Collaborator.cs @@ -88,7 +88,7 @@ internal string DebuggerDisplay get { return string.Format(CultureInfo.InvariantCulture, - "Author: Id: {0} Login: {1}", Id, Login); + "Collaborator: Id: {0} Login: {1}", Id, Login); } } } From 50ff3c5c54182fc505acc4f518eae6af203a3586 Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 12:57:20 +0600 Subject: [PATCH 11/39] update list collaborators method signature --- .../Extensions.cs | 16 +++++++-------- .../IObservableRepoCollaboratorsClient.cs | 16 +++++++-------- .../ObservableRepoCollaboratorsClient.cs | 20 +++++++++---------- Octokit/Clients/IRepoCollaboratorsClient.cs | 16 +++++++-------- Octokit/Clients/RepoCollaboratorsClient.cs | 20 +++++++++---------- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Octokit.AsyncPaginationExtension/Extensions.cs b/Octokit.AsyncPaginationExtension/Extensions.cs index c541ac0bd8..cd131c8da3 100644 --- a/Octokit.AsyncPaginationExtension/Extensions.cs +++ b/Octokit.AsyncPaginationExtension/Extensions.cs @@ -547,20 +547,20 @@ public static IPaginatedList GetAllAssetsAsync(this IReleasesClien => pageSize > 0 ? new PaginatedList(options => t.GetAllAssets(repositoryId, id, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// - public static IPaginatedList GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + public static IPaginatedList GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList(options => t.GetAll(owner, name, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// - public static IPaginatedList GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + public static IPaginatedList GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList(options => t.GetAll(repositoryId, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// - public static IPaginatedList GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + public static IPaginatedList GetAllAsync(this IRepoCollaboratorsClient t, string owner, string name, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList(options => t.GetAll(owner, name, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// - public static IPaginatedList GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) - => pageSize > 0 ? new PaginatedList(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); + public static IPaginatedList GetAllAsync(this IRepoCollaboratorsClient t, long repositoryId, RepositoryCollaboratorListRequest request, int pageSize = DEFAULT_PAGE_SIZE) + => pageSize > 0 ? new PaginatedList(options => t.GetAll(repositoryId, request, options), pageSize) : throw new ArgumentOutOfRangeException(nameof(pageSize), pageSize, "The page size must be positive."); /// public static IPaginatedList GetAllForCurrentAsync(this IRepositoriesClient t, int pageSize = DEFAULT_PAGE_SIZE) diff --git a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs index 18c2f8b06d..82c70386ce 100644 --- a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs @@ -20,7 +20,7 @@ public interface IObservableRepoCollaboratorsClient /// The owner of the repository /// The name of the repository /// Thrown when a general API error occurs. - IObservable GetAll(string owner, string name); + IObservable GetAll(string owner, string name); /// /// Gets all the collaborators on a repository. @@ -30,7 +30,7 @@ public interface IObservableRepoCollaboratorsClient /// /// The id of the repository /// Thrown when a general API error occurs. - IObservable GetAll(long repositoryId); + IObservable GetAll(long repositoryId); /// /// Gets all the collaborators on a repository. @@ -42,7 +42,7 @@ public interface IObservableRepoCollaboratorsClient /// The name of the repository /// Options for changing the API response /// Thrown when a general API error occurs. - IObservable GetAll(string owner, string name, ApiOptions options); + IObservable GetAll(string owner, string name, ApiOptions options); /// /// Gets all the collaborators on a repository. @@ -53,7 +53,7 @@ public interface IObservableRepoCollaboratorsClient /// The id of the repository /// Options for changing the API response /// Thrown when a general API error occurs. - IObservable GetAll(long repositoryId, ApiOptions options); + IObservable GetAll(long repositoryId, ApiOptions options); /// /// Gets all the collaborators on a repository. @@ -65,7 +65,7 @@ public interface IObservableRepoCollaboratorsClient /// The name of the repository /// Used to request and filter a list of repository collaborators /// Thrown when a general API error occurs. - IObservable GetAll(string owner, string name, RepositoryCollaboratorListRequest request); + IObservable GetAll(string owner, string name, RepositoryCollaboratorListRequest request); /// /// Gets all the collaborators on a repository. @@ -76,7 +76,7 @@ public interface IObservableRepoCollaboratorsClient /// The id of the repository /// Used to request and filter a list of repository collaborators /// Thrown when a general API error occurs. - IObservable GetAll(long repositoryId, RepositoryCollaboratorListRequest request); + IObservable GetAll(long repositoryId, RepositoryCollaboratorListRequest request); /// /// Gets all the collaborators on a repository. @@ -89,7 +89,7 @@ public interface IObservableRepoCollaboratorsClient /// Used to request and filter a list of repository collaborators /// Options for changing the API response /// Thrown when a general API error occurs. - IObservable GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options); + IObservable GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options); /// /// Gets all the collaborators on a repository. @@ -101,7 +101,7 @@ public interface IObservableRepoCollaboratorsClient /// Used to request and filter a list of repository collaborators /// Options for changing the API response /// Thrown when a general API error occurs. - IObservable GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options); + IObservable GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options); /// /// Checks if a user is a collaborator on a repository. diff --git a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs index d9c7cd78ad..b736c2cfb3 100644 --- a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs @@ -37,7 +37,7 @@ public ObservableRepoCollaboratorsClient(IGitHubClient client) /// The owner of the repository /// The name of the repository /// Thrown when a general API error occurs. - public IObservable GetAll(string owner, string name) + public IObservable GetAll(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -53,7 +53,7 @@ public IObservable GetAll(string owner, string name) /// /// The id of the repository /// Thrown when a general API error occurs. - public IObservable GetAll(long repositoryId) + public IObservable GetAll(long repositoryId) { return GetAll(repositoryId, ApiOptions.None); } @@ -68,7 +68,7 @@ public IObservable GetAll(long repositoryId) /// The name of the repository /// Options for changing the API response /// Thrown when a general API error occurs. - public IObservable GetAll(string owner, string name, ApiOptions options) + public IObservable GetAll(string owner, string name, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -86,7 +86,7 @@ public IObservable GetAll(string owner, string name, ApiOptions options) /// The id of the repository /// Options for changing the API response /// Thrown when a general API error occurs. - public IObservable GetAll(long repositoryId, ApiOptions options) + public IObservable GetAll(long repositoryId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); @@ -103,7 +103,7 @@ public IObservable GetAll(long repositoryId, ApiOptions options) /// The name of the repository /// Used to request and filter a list of repository collaborators /// Thrown when a general API error occurs. - public IObservable GetAll(string owner, string name, RepositoryCollaboratorListRequest request) + public IObservable GetAll(string owner, string name, RepositoryCollaboratorListRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -121,7 +121,7 @@ public IObservable GetAll(string owner, string name, RepositoryCollaborato /// The id of the repository /// Used to request and filter a list of repository collaborators /// Thrown when a general API error occurs. - public IObservable GetAll(long repositoryId, RepositoryCollaboratorListRequest request) + public IObservable GetAll(long repositoryId, RepositoryCollaboratorListRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); @@ -139,14 +139,14 @@ public IObservable GetAll(long repositoryId, RepositoryCollaboratorListReq /// Used to request and filter a list of repository collaborators /// Options for changing the API response /// Thrown when a general API error occurs. - public IObservable GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options) + public IObservable GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages(ApiUrls.RepoCollaborators(owner, name), request.ToParametersDictionary(), options); + return _connection.GetAndFlattenAllPages(ApiUrls.RepoCollaborators(owner, name), request.ToParametersDictionary(), options); } /// @@ -159,12 +159,12 @@ public IObservable GetAll(string owner, string name, RepositoryCollaborato /// Used to request and filter a list of repository collaborators /// Options for changing the API response /// Thrown when a general API error occurs. - public IObservable GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options) + public IObservable GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages(ApiUrls.RepoCollaborators(repositoryId), request.ToParametersDictionary(), options); + return _connection.GetAndFlattenAllPages(ApiUrls.RepoCollaborators(repositoryId), request.ToParametersDictionary(), options); } /// diff --git a/Octokit/Clients/IRepoCollaboratorsClient.cs b/Octokit/Clients/IRepoCollaboratorsClient.cs index 280473f2bd..bbd3873bd4 100644 --- a/Octokit/Clients/IRepoCollaboratorsClient.cs +++ b/Octokit/Clients/IRepoCollaboratorsClient.cs @@ -20,7 +20,7 @@ public interface IRepoCollaboratorsClient /// The owner of the repository /// The name of the repository /// Thrown when a general API error occurs. - Task> GetAll(string owner, string name); + Task> GetAll(string owner, string name); /// /// Gets all the collaborators on a repository. @@ -30,7 +30,7 @@ public interface IRepoCollaboratorsClient /// /// The id of the repository /// Thrown when a general API error occurs. - Task> GetAll(long repositoryId); + Task> GetAll(long repositoryId); /// /// Gets all the collaborators on a repository. @@ -42,7 +42,7 @@ public interface IRepoCollaboratorsClient /// The name of the repository /// Options for changing the API response /// Thrown when a general API error occurs. - Task> GetAll(string owner, string name, ApiOptions options); + Task> GetAll(string owner, string name, ApiOptions options); /// /// Gets all the collaborators on a repository. @@ -53,7 +53,7 @@ public interface IRepoCollaboratorsClient /// The id of the repository /// Options for changing the API response /// Thrown when a general API error occurs. - Task> GetAll(long repositoryId, ApiOptions options); + Task> GetAll(long repositoryId, ApiOptions options); /// /// Gets all the collaborators on a repository. @@ -65,7 +65,7 @@ public interface IRepoCollaboratorsClient /// The name of the repository /// Used to request and filter a list of repository collaborators /// Thrown when a general API error occurs. - Task> GetAll(string owner, string name, RepositoryCollaboratorListRequest request); + Task> GetAll(string owner, string name, RepositoryCollaboratorListRequest request); /// /// Gets all the collaborators on a repository. @@ -76,7 +76,7 @@ public interface IRepoCollaboratorsClient /// The id of the repository /// Used to request and filter a list of repository collaborators /// Thrown when a general API error occurs. - Task> GetAll(long repositoryId, RepositoryCollaboratorListRequest request); + Task> GetAll(long repositoryId, RepositoryCollaboratorListRequest request); /// /// Gets all the collaborators on a repository. @@ -89,7 +89,7 @@ public interface IRepoCollaboratorsClient /// Used to request and filter a list of repository collaborators /// Options for changing the API response /// Thrown when a general API error occurs. - Task> GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options); + Task> GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options); /// /// Gets all the collaborators on a repository. @@ -101,7 +101,7 @@ public interface IRepoCollaboratorsClient /// Used to request and filter a list of repository collaborators /// Options for changing the API response /// Thrown when a general API error occurs. - Task> GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options); + Task> GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options); /// /// Checks if a user is a collaborator on a repository. diff --git a/Octokit/Clients/RepoCollaboratorsClient.cs b/Octokit/Clients/RepoCollaboratorsClient.cs index 09433023c4..dcd026e56a 100644 --- a/Octokit/Clients/RepoCollaboratorsClient.cs +++ b/Octokit/Clients/RepoCollaboratorsClient.cs @@ -30,7 +30,7 @@ public RepoCollaboratorsClient(IApiConnection apiConnection) /// The name of the repository /// Thrown when a general API error occurs. [ManualRoute("GET", "/repos/{owner}/{repo}/collaborators")] - public Task> GetAll(string owner, string name) + public Task> GetAll(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -47,7 +47,7 @@ public Task> GetAll(string owner, string name) /// The id of the repository /// Thrown when a general API error occurs. [ManualRoute("GET", "/repository/{id}/collaborators")] - public Task> GetAll(long repositoryId) + public Task> GetAll(long repositoryId) { return GetAll(repositoryId, ApiOptions.None); } @@ -63,7 +63,7 @@ public Task> GetAll(long repositoryId) /// Options for changing the API response /// Thrown when a general API error occurs. [ManualRoute("GET", "/repos/{owner}/{repo}/collaborators")] - public Task> GetAll(string owner, string name, ApiOptions options) + public Task> GetAll(string owner, string name, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -82,7 +82,7 @@ public Task> GetAll(string owner, string name, ApiOptions op /// Options for changing the API response /// Thrown when a general API error occurs. [ManualRoute("GET", "/repository/{id}/collaborators")] - public Task> GetAll(long repositoryId, ApiOptions options) + public Task> GetAll(long repositoryId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); @@ -100,7 +100,7 @@ public Task> GetAll(long repositoryId, ApiOptions options) /// Used to request and filter a list of repository collaborators /// Thrown when a general API error occurs. [ManualRoute("GET", "/repos/{owner}/{repo}/collaborators")] - public Task> GetAll(string owner, string name, RepositoryCollaboratorListRequest request) + public Task> GetAll(string owner, string name, RepositoryCollaboratorListRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); @@ -119,7 +119,7 @@ public Task> GetAll(string owner, string name, RepositoryCol /// Used to request and filter a list of repository collaborators /// Thrown when a general API error occurs. [ManualRoute("GET", "/repository/{id}/collaborators")] - public Task> GetAll(long repositoryId, RepositoryCollaboratorListRequest request) + public Task> GetAll(long repositoryId, RepositoryCollaboratorListRequest request) { Ensure.ArgumentNotNull(request, nameof(request)); @@ -138,14 +138,14 @@ public Task> GetAll(long repositoryId, RepositoryCollaborato /// Options for changing the API response /// Thrown when a general API error occurs. [ManualRoute("GET", "/repos/{owner}/{repo}/collaborators")] - public Task> GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options) + public Task> GetAll(string owner, string name, RepositoryCollaboratorListRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll(ApiUrls.RepoCollaborators(owner, name), request.ToParametersDictionary(), options); + return ApiConnection.GetAll(ApiUrls.RepoCollaborators(owner, name), request.ToParametersDictionary(), options); } @@ -160,12 +160,12 @@ public Task> GetAll(string owner, string name, RepositoryCol /// Options for changing the API response /// Thrown when a general API error occurs. [ManualRoute("GET", "/repository/{id}/collaborators")] - public Task> GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options) + public Task> GetAll(long repositoryId, RepositoryCollaboratorListRequest request, ApiOptions options) { Ensure.ArgumentNotNull(request, nameof(request)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll(ApiUrls.RepoCollaborators(repositoryId), request.ToParametersDictionary(), options); + return ApiConnection.GetAll(ApiUrls.RepoCollaborators(repositoryId), request.ToParametersDictionary(), options); } /// From 9dbe36c689c5ef26d73dc3f069c238a6c669afc6 Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 13:06:46 +0600 Subject: [PATCH 12/39] fix wrong references to api docs --- .../Clients/IObservableRepoCollaboratorsClient.cs | 4 ++-- .../Clients/ObservableRepoCollaboratorsClient.cs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs index 82c70386ce..3df2a0d333 100644 --- a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs @@ -165,7 +165,7 @@ public interface IObservableRepoCollaboratorsClient /// Adds a new collaborator to the repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -247,7 +247,7 @@ public interface IObservableRepoCollaboratorsClient /// Deletes a collaborator from the repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository diff --git a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs index b736c2cfb3..d21ee625d1 100644 --- a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs @@ -171,7 +171,7 @@ public IObservable GetAll(long repositoryId, RepositoryCollaborato /// Checks if a user is a collaborator on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -297,7 +297,7 @@ public IObservable Add(long repositoryId, string user) /// Adds a new collaborator to the repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Username of the new collaborator @@ -315,7 +315,7 @@ public IObservable Add(long repositoryId, string user, Col /// Invites a user as a collaborator to a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -333,7 +333,7 @@ public IObservable Invite(string owner, string name, strin /// Invites a user as a collaborator to a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -353,7 +353,7 @@ public IObservable Invite(string owner, string name, strin /// Invites a user as a collaborator to a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// The username of the prospective collaborator @@ -369,7 +369,7 @@ public IObservable Invite(long repositoryId, string user) /// Invites a user as a collaborator to a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// The username of the prospective collaborator @@ -386,7 +386,7 @@ public IObservable Invite(long repositoryId, string user, /// Deletes a collaborator from the repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository From b44c9132f0056e477c2d7a71934554cc99283d54 Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 13:10:38 +0600 Subject: [PATCH 13/39] update api doc links --- .../IObservableRepoCollaboratorsClient.cs | 20 +++++++++---------- .../ObservableRepoCollaboratorsClient.cs | 16 +++++++-------- Octokit/Clients/IRepoCollaboratorsClient.cs | 16 +++++++-------- Octokit/Clients/RepoCollaboratorsClient.cs | 16 +++++++-------- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs index 3df2a0d333..4c442b97dc 100644 --- a/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepoCollaboratorsClient.cs @@ -15,7 +15,7 @@ public interface IObservableRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -26,7 +26,7 @@ public interface IObservableRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Thrown when a general API error occurs. @@ -36,7 +36,7 @@ public interface IObservableRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -48,7 +48,7 @@ public interface IObservableRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Options for changing the API response @@ -59,7 +59,7 @@ public interface IObservableRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -71,7 +71,7 @@ public interface IObservableRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Used to request and filter a list of repository collaborators @@ -82,7 +82,7 @@ public interface IObservableRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -95,7 +95,7 @@ public interface IObservableRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Used to request and filter a list of repository collaborators @@ -107,7 +107,7 @@ public interface IObservableRepoCollaboratorsClient /// Checks if a user is a collaborator on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -153,7 +153,7 @@ public interface IObservableRepoCollaboratorsClient /// Adds a new collaborator to the repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository diff --git a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs index d21ee625d1..bae3ee476e 100644 --- a/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs @@ -32,7 +32,7 @@ public ObservableRepoCollaboratorsClient(IGitHubClient client) /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -49,7 +49,7 @@ public IObservable GetAll(string owner, string name) /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Thrown when a general API error occurs. @@ -62,7 +62,7 @@ public IObservable GetAll(long repositoryId) /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -81,7 +81,7 @@ public IObservable GetAll(string owner, string name, ApiOptions op /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Options for changing the API response @@ -97,7 +97,7 @@ public IObservable GetAll(long repositoryId, ApiOptions options) /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -116,7 +116,7 @@ public IObservable GetAll(string owner, string name, RepositoryCol /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Used to request and filter a list of repository collaborators @@ -132,7 +132,7 @@ public IObservable GetAll(long repositoryId, RepositoryCollaborato /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -153,7 +153,7 @@ public IObservable GetAll(string owner, string name, RepositoryCol /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Used to request and filter a list of repository collaborators diff --git a/Octokit/Clients/IRepoCollaboratorsClient.cs b/Octokit/Clients/IRepoCollaboratorsClient.cs index bbd3873bd4..7f65ccf7a2 100644 --- a/Octokit/Clients/IRepoCollaboratorsClient.cs +++ b/Octokit/Clients/IRepoCollaboratorsClient.cs @@ -15,7 +15,7 @@ public interface IRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -26,7 +26,7 @@ public interface IRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Thrown when a general API error occurs. @@ -36,7 +36,7 @@ public interface IRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -48,7 +48,7 @@ public interface IRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Options for changing the API response @@ -59,7 +59,7 @@ public interface IRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -71,7 +71,7 @@ public interface IRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Used to request and filter a list of repository collaborators @@ -82,7 +82,7 @@ public interface IRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -95,7 +95,7 @@ public interface IRepoCollaboratorsClient /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Used to request and filter a list of repository collaborators diff --git a/Octokit/Clients/RepoCollaboratorsClient.cs b/Octokit/Clients/RepoCollaboratorsClient.cs index dcd026e56a..7cfc1e0800 100644 --- a/Octokit/Clients/RepoCollaboratorsClient.cs +++ b/Octokit/Clients/RepoCollaboratorsClient.cs @@ -24,7 +24,7 @@ public RepoCollaboratorsClient(IApiConnection apiConnection) /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -42,7 +42,7 @@ public Task> GetAll(string owner, string name) /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Thrown when a general API error occurs. @@ -56,7 +56,7 @@ public Task> GetAll(long repositoryId) /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -76,7 +76,7 @@ public Task> GetAll(string owner, string name, ApiOp /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Options for changing the API response @@ -93,7 +93,7 @@ public Task> GetAll(long repositoryId, ApiOptions op /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -113,7 +113,7 @@ public Task> GetAll(string owner, string name, Repos /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Used to request and filter a list of repository collaborators @@ -130,7 +130,7 @@ public Task> GetAll(long repositoryId, RepositoryCol /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The owner of the repository /// The name of the repository @@ -153,7 +153,7 @@ public Task> GetAll(string owner, string name, Repos /// Gets all the collaborators on a repository. /// /// - /// See the API documentation for more information. + /// See the API documentation for more information. /// /// The id of the repository /// Used to request and filter a list of repository collaborators From 5a87115f73485570c0ccc404acac9787d28a5744 Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 19:29:56 +0600 Subject: [PATCH 14/39] update tests --- .../Clients/RepoCollaboratorsClientTests.cs | 20 ++++++------- .../ObservableRepoCollaboratorsClientTests.cs | 28 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs index 7346217d14..e15d8fb8ad 100644 --- a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs +++ b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs @@ -35,7 +35,7 @@ public void RequestsCorrectUrl() client.GetAll("owner", "test"); - connection.Received().GetAll( + connection.Received().GetAll( Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), Arg.Any>(), Args.ApiOptions); @@ -49,7 +49,7 @@ public void RequestsCorrectUrlWithRepositoryId() client.GetAll(1); - connection.Received().GetAll( + connection.Received().GetAll( Arg.Is(u => u.ToString() == "repositories/1/collaborators"), Arg.Any>(), Args.ApiOptions); @@ -71,7 +71,7 @@ public void RequestsCorrectUrlWithApiOptions() client.GetAll("owner", "test", options); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), Arg.Any>(), options); } @@ -87,7 +87,7 @@ public void RequestsCorrectUrlWithCollaboratorFilter() client.GetAll("owner", "test", request); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), Arg.Is>(d => d["affiliation"] == "all"), Args.ApiOptions); @@ -99,7 +99,7 @@ public void RequestsCorrectUrlWithCollaboratorFilter() client.GetAll("owner", "test", request); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), Arg.Is>(d => d["affiliation"] == "direct"), Args.ApiOptions); @@ -111,7 +111,7 @@ public void RequestsCorrectUrlWithCollaboratorFilter() client.GetAll("owner", "test", request); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), Arg.Is>(d => d["affiliation"] == "outside"), Args.ApiOptions); } @@ -132,7 +132,7 @@ public void RequestsCorrectUrlWithApiOptionsAndRepositoryId() client.GetAll(1, options); connection.Received() - .GetAll( + .GetAll( Arg.Is(u => u.ToString() == "repositories/1/collaborators"), Arg.Any>(), options); @@ -149,7 +149,7 @@ public void RequestsCorrectUrlWithCollaboratorFilterAndRepositoryId() client.GetAll(1, request); connection.Received() - .GetAll( + .GetAll( Arg.Is(u => u.ToString() == "repositories/1/collaborators"), Arg.Is>(d => d["affiliation"] == "all"), Args.ApiOptions); @@ -162,7 +162,7 @@ public void RequestsCorrectUrlWithCollaboratorFilterAndRepositoryId() client.GetAll(1, request); connection.Received() - .GetAll( + .GetAll( Arg.Is(u => u.ToString() == "repositories/1/collaborators"), Arg.Is>(d => d["affiliation"] == "direct"), Args.ApiOptions); @@ -175,7 +175,7 @@ public void RequestsCorrectUrlWithCollaboratorFilterAndRepositoryId() client.GetAll(1, request); connection.Received() - .GetAll( + .GetAll( Arg.Is(u => u.ToString() == "repositories/1/collaborators"), Arg.Is>(d => d["affiliation"] == "outside"), Args.ApiOptions); diff --git a/Octokit.Tests/Reactive/ObservableRepoCollaboratorsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepoCollaboratorsClientTests.cs index d48a007a96..a589491c8f 100644 --- a/Octokit.Tests/Reactive/ObservableRepoCollaboratorsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepoCollaboratorsClientTests.cs @@ -68,7 +68,7 @@ public void RequestsCorrectUrl() _client.GetAll(owner, name); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(dictionary => dictionary.Count == 1)); } @@ -79,7 +79,7 @@ public void RequestsCorrectUrlWithRepositoryId() _client.GetAll(repositoryId); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(dictionary => dictionary.Count == 1)); } @@ -98,7 +98,7 @@ public void RequestsCorrectUrlWithApiOptions() _client.GetAll(owner, name, options); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(dictionary => dictionary.Count == 3)); // StartPage is setted => only 1 option (StartPage) in dictionary @@ -109,7 +109,7 @@ public void RequestsCorrectUrlWithApiOptions() _client.GetAll(owner, name, options); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(dictionary => dictionary.Count == 2)); // PageCount is setted => none of options in dictionary @@ -120,7 +120,7 @@ public void RequestsCorrectUrlWithApiOptions() _client.GetAll(owner, name, options); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(dictionary => dictionary.Count == 1)); } @@ -133,7 +133,7 @@ public void RequestsCorrectUrlWithCollaboratorFilter() _client.GetAll(owner, name, request); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(d => d["affiliation"] == "all")); request = new RepositoryCollaboratorListRequest @@ -143,7 +143,7 @@ public void RequestsCorrectUrlWithCollaboratorFilter() _client.GetAll(owner, name, request); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(d => d["affiliation"] == "direct")); // PageCount is setted => none of options in dictionary @@ -154,7 +154,7 @@ public void RequestsCorrectUrlWithCollaboratorFilter() _client.GetAll(owner, name, request); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(d => d["affiliation"] == "outside")); } @@ -173,7 +173,7 @@ public void RequestsCorrectUrlWithApiOptionsAndRepositoryId() _client.GetAll(repositoryId, options); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(dictionary => dictionary.Count == 3)); // StartPage is setted => only 1 option (StartPage) in dictionary @@ -184,7 +184,7 @@ public void RequestsCorrectUrlWithApiOptionsAndRepositoryId() _client.GetAll(repositoryId, options); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(dictionary => dictionary.Count == 2)); // PageCount is setted => none of options in dictionary @@ -195,7 +195,7 @@ public void RequestsCorrectUrlWithApiOptionsAndRepositoryId() _client.GetAll(repositoryId, options); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(dictionary => dictionary.Count == 1)); } @@ -208,7 +208,7 @@ public void RequestsCorrectUrlWithCollaboratorFilterAndRepositoryId() _client.GetAll(repositoryId, request); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(d => d["affiliation"] == "all")); request = new RepositoryCollaboratorListRequest @@ -218,7 +218,7 @@ public void RequestsCorrectUrlWithCollaboratorFilterAndRepositoryId() _client.GetAll(repositoryId, request); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(d => d["affiliation"] == "direct")); request = new RepositoryCollaboratorListRequest @@ -228,7 +228,7 @@ public void RequestsCorrectUrlWithCollaboratorFilterAndRepositoryId() _client.GetAll(repositoryId, request); _githubClient.Connection.Received(1) - .Get>(Arg.Is(u => u.ToString() == expectedUrl), + .Get>(Arg.Is(u => u.ToString() == expectedUrl), Arg.Is>(d => d["affiliation"] == "outside")); } } From f25a1d09ed52a293aeb8036766e8f5f61476dd21 Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 20:31:57 +0600 Subject: [PATCH 15/39] refactor: permission as string --- .../RepositoryCollaboratorClientTests.cs | 2 +- .../RepositoryInvitationsClientTests.cs | 24 +++++++++---------- .../Clients/RepoCollaboratorsClientTests.cs | 8 +++---- .../ObservableRepoCollaboratorsClientTests.cs | 8 +++---- Octokit/Models/Request/CollaboratorRequest.cs | 7 ++++-- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs index 247ac81dc0..380540eac8 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs @@ -470,7 +470,7 @@ public async Task CanInviteNewCollaborator() using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, "octokat", permission); diff --git a/Octokit.Tests.Integration/Clients/RepositoryInvitationsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryInvitationsClientTests.cs index e05b52b5b0..a3590942eb 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryInvitationsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryInvitationsClientTests.cs @@ -20,7 +20,7 @@ public async Task CanGetAllInvitations() using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, collaborator, permission); @@ -50,7 +50,7 @@ public async Task ReturnsCorrectCountOfInvitationsWithStart() using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator var response1 = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, collaborator1, permission); @@ -86,7 +86,7 @@ public async Task ReturnsCorrectCountOfInvitationsWithoutStart() using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, collaborator, permission); @@ -116,7 +116,7 @@ public async Task ReturnsDistinctInvitationsBasedOnStart() using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator var response1 = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, collaborator1, permission); @@ -161,7 +161,7 @@ public async Task CanGetAllInvitations() using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission); @@ -195,7 +195,7 @@ public async Task ReturnsCorrectCountOfInvitationsWithStart() contexts.Add(await github.CreateRepositoryContext(new NewRepository(repoName))); } var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator to all repos foreach (var context in contexts) @@ -243,7 +243,7 @@ public async Task ReturnsCorrectCountOfInvitationsWithoutStart() contexts.Add(await github.CreateRepositoryContext(new NewRepository(repoName))); } var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator to all repos foreach (var context in contexts) @@ -290,7 +290,7 @@ public async Task ReturnsDistinctInvitationsBasedOnStart() contexts.Add(await github.CreateRepositoryContext(new NewRepository(repoName))); } var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator to all repos foreach (var context in contexts) @@ -351,7 +351,7 @@ public async Task CanAcceptInvitation() using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission); @@ -378,7 +378,7 @@ public async Task CanDeclineInvitation() using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission); @@ -406,7 +406,7 @@ public async Task CanDeleteInvitation() using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission); @@ -433,7 +433,7 @@ public async Task CanUpdateInvitation() using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = github.Repository.Collaborator; - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); // invite a collaborator var response = await fixture.Invite(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner, permission); diff --git a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs index e15d8fb8ad..ef4f160e36 100644 --- a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs +++ b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs @@ -393,8 +393,8 @@ public async Task SurfacesAuthorizationExceptionWhenSpecifyingCollaboratorReques connection.Put(Arg.Any(), Arg.Any()).ThrowsAsync(new AuthorizationException()); - await Assert.ThrowsAsync(() => client.Add("owner", "test", "user1", new CollaboratorRequest(Permission.Pull))); - await Assert.ThrowsAsync(() => client.Add(1, "user1", new CollaboratorRequest(Permission.Pull))); + await Assert.ThrowsAsync(() => client.Add("owner", "test", "user1", new CollaboratorRequest("pull"))); + await Assert.ThrowsAsync(() => client.Add(1, "user1", new CollaboratorRequest("pull"))); } } @@ -406,7 +406,7 @@ public void RequestsCorrectUrl() var connection = Substitute.For(); var client = new RepoCollaboratorsClient(connection); - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); client.Invite("owner", "test", "user1", permission); connection.Received().Put(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators/user1"), Arg.Is(permission)); @@ -416,7 +416,7 @@ public void RequestsCorrectUrl() public async Task EnsuresNonNullArguments() { var client = new RepoCollaboratorsClient(Substitute.For()); - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); await Assert.ThrowsAsync(() => client.Invite(null, "test", "user1", permission)); await Assert.ThrowsAsync(() => client.Invite("", "test", "user1", permission)); diff --git a/Octokit.Tests/Reactive/ObservableRepoCollaboratorsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepoCollaboratorsClientTests.cs index a589491c8f..7876db4bcc 100644 --- a/Octokit.Tests/Reactive/ObservableRepoCollaboratorsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepoCollaboratorsClientTests.cs @@ -507,7 +507,7 @@ private void SetupWithNonReactiveClient() public void EnsuresNonNullArguments() { SetupWithNonReactiveClient(); - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); Assert.Throws(() => _client.Invite(null, "repo", "user", permission)); Assert.Throws(() => _client.Invite("owner", null, "user", permission)); @@ -519,7 +519,7 @@ public void EnsuresNonNullArguments() public void EnsuresNonEmptyArguments() { SetupWithNonReactiveClient(); - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); Assert.Throws(() => _client.Invite("", "repo", "user", permission)); Assert.Throws(() => _client.Invite("owner", "", "user", permission)); @@ -530,7 +530,7 @@ public void EnsuresNonEmptyArguments() public async Task EnsuresNonWhitespaceArguments() { SetupWithNonReactiveClient(); - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); await AssertEx.ThrowsWhenGivenWhitespaceArgument( async whitespace => await _client.Invite(whitespace, "repo", "user", permission)); @@ -544,7 +544,7 @@ await AssertEx.ThrowsWhenGivenWhitespaceArgument( public void CallsInviteOnRegularDeploymentsClient() { SetupWithoutNonReactiveClient(); - var permission = new CollaboratorRequest(Permission.Push); + var permission = new CollaboratorRequest("push"); _client.Invite("owner", "repo", "user", permission); diff --git a/Octokit/Models/Request/CollaboratorRequest.cs b/Octokit/Models/Request/CollaboratorRequest.cs index a6776d617c..74db378c8e 100644 --- a/Octokit/Models/Request/CollaboratorRequest.cs +++ b/Octokit/Models/Request/CollaboratorRequest.cs @@ -9,15 +9,18 @@ public class CollaboratorRequest /// /// Used to set the permission for a collaborator. /// - public CollaboratorRequest(Permission permissions) + public CollaboratorRequest(string permissions) { Permission = permissions; } /// /// The permission to grant the collaborator on this repository. + /// Only valid on organization-owned repositories. We accept the following permissions to be set: + /// pull, triage, push, maintain, admin and you can also specify a custom repository role name, + /// if the owning organization has defined any. /// - public Permission Permission { get; private set; } + public string Permission { get; private set; } internal string DebuggerDisplay { From b7af2b1965dcd06fe122f5979cffd55834e98b09 Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 20:38:21 +0600 Subject: [PATCH 16/39] rename permission to TeamPermissionLegacy --- .../Clients/RepositoryBranchesClientTests.cs | 8 ++--- .../Clients/TeamsClientTests.cs | 2 +- .../OrganizationRepositoryWithTeamContext.cs | 4 +-- Octokit.Tests/Clients/TeamsClientTests.cs | 2 +- Octokit/Models/Common/Permission.cs | 35 ++++--------------- .../Request/RepositoryPermissionRequest.cs | 4 +-- 6 files changed, 16 insertions(+), 39 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs index f2798554fa..682fe7f3c5 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs @@ -1241,7 +1241,7 @@ await _github.Organization.Team.AddRepository( team2.TeamId, repoContext.RepositoryOwner, repoContext.RepositoryName, - new RepositoryPermissionRequest(Permission.Push)); + new RepositoryPermissionRequest(TeamPermissionLegacy.Push)); var newTeam = new BranchProtectionTeamCollection() { team2.TeamName }; var restrictions = await _github.Repository.Branch.UpdateProtectedBranchTeamRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, newTeam); @@ -1265,7 +1265,7 @@ await _github.Organization.Team.AddRepository( team2.TeamId, repoContext.RepositoryOwner, repoContext.RepositoryName, - new RepositoryPermissionRequest(Permission.Push)); + new RepositoryPermissionRequest(TeamPermissionLegacy.Push)); var newTeam = new BranchProtectionTeamCollection() { team2.TeamName }; var restrictions = await _github.Repository.Branch.UpdateProtectedBranchTeamRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, newTeam); @@ -1292,7 +1292,7 @@ await _github.Organization.Team.AddRepository( team2.TeamId, repoContext.RepositoryOwner, repoContext.RepositoryName, - new RepositoryPermissionRequest(Permission.Push)); + new RepositoryPermissionRequest(TeamPermissionLegacy.Push)); var newTeam = new BranchProtectionTeamCollection() { team2.TeamName }; var restrictions = await _github.Repository.Branch.AddProtectedBranchTeamRestrictions(repoContext.RepositoryOwner, repoContext.RepositoryName, repoContext.RepositoryDefaultBranch, newTeam); @@ -1316,7 +1316,7 @@ await _github.Organization.Team.AddRepository( team2.TeamId, repoContext.RepositoryOwner, repoContext.RepositoryName, - new RepositoryPermissionRequest(Permission.Push)); + new RepositoryPermissionRequest(TeamPermissionLegacy.Push)); var newTeam = new BranchProtectionTeamCollection() { team2.TeamName }; var restrictions = await _github.Repository.Branch.AddProtectedBranchTeamRestrictions(repoContext.RepositoryId, repoContext.RepositoryDefaultBranch, newTeam); diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs index 0735cc2f60..5cbd7ba8a0 100644 --- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs @@ -326,7 +326,7 @@ public async Task CanAddRepository() var team = teamContext.Team; var repo = repoContext.Repository; - var addRepo = await _github.Organization.Team.AddRepository(team.Id, team.Organization.Login, repo.Name, new RepositoryPermissionRequest(Permission.Admin)); + var addRepo = await _github.Organization.Team.AddRepository(team.Id, team.Organization.Login, repo.Name, new RepositoryPermissionRequest(TeamPermissionLegacy.Admin)); Assert.True(addRepo); diff --git a/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs b/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs index df568cfef6..ab010f9386 100644 --- a/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs +++ b/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs @@ -73,7 +73,7 @@ await client.Organization.Team.AddRepository( team.TeamId, repoContext.RepositoryOwner, repoContext.RepositoryName, - new RepositoryPermissionRequest(Permission.Push)); + new RepositoryPermissionRequest(TeamPermissionLegacy.Push)); // Protect default branch var protection = new BranchProtectionSettingsUpdate( @@ -100,7 +100,7 @@ await client.Organization.Team.AddRepository( contextOrgTeam.TeamId, contextOrgRepo.RepositoryOwner, contextOrgRepo.RepositoryName, - new RepositoryPermissionRequest(Permission.Push)); + new RepositoryPermissionRequest(TeamPermissionLegacy.Push)); // Protect default branch var protection = new BranchProtectionSettingsUpdate( diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index b29e921c07..7f11425840 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -416,7 +416,7 @@ public async Task AddOrUpdatePermission() { var connection = Substitute.For(); var client = new TeamsClient(connection); - var newPermission = new RepositoryPermissionRequest(Permission.Admin); + var newPermission = new RepositoryPermissionRequest(TeamPermissionLegacy.Admin); await client.AddRepository(1, "org", "repo", newPermission); diff --git a/Octokit/Models/Common/Permission.cs b/Octokit/Models/Common/Permission.cs index c0643fd663..6b042fbb31 100644 --- a/Octokit/Models/Common/Permission.cs +++ b/Octokit/Models/Common/Permission.cs @@ -6,40 +6,17 @@ namespace Octokit { /// - /// Used to describe a permission level. + /// The permission to grant the team on this repository(Legacy). /// [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] - public enum Permission + public enum TeamPermissionLegacy { - /// - /// team members can pull, push and administer these repositories. - /// - [Parameter(Value = "admin")] - Admin, - - /// - /// team members can manage the repository without access to sensitive or destructive actions. Recommended for project managers. Only applies to repositories owned by organizations. - /// - [Parameter(Value = "maintain")] - Maintain, - - /// - /// team members can proactively manage issues and pull requests without write access. Recommended for contributors who triage a repository. Only applies to repositories owned by organizations. - /// - [Parameter(Value = "triage")] - Triage, - - /// - /// team members can pull and push, but not administer these repositories - /// + [Parameter(Value = "pull")] + Pull, [Parameter(Value = "push")] Push, - - /// - /// team members can pull, but not push to or administer these repositories - /// - [Parameter(Value = "pull")] - Pull + [Parameter(Value = "admin")] + Admin } /// diff --git a/Octokit/Models/Request/RepositoryPermissionRequest.cs b/Octokit/Models/Request/RepositoryPermissionRequest.cs index 9475b01195..184892dfa0 100644 --- a/Octokit/Models/Request/RepositoryPermissionRequest.cs +++ b/Octokit/Models/Request/RepositoryPermissionRequest.cs @@ -10,7 +10,7 @@ public class RepositoryPermissionRequest /// /// Used to add or update a team repository. /// - public RepositoryPermissionRequest(Permission permission) + public RepositoryPermissionRequest(TeamPermissionLegacy permission) { Permission = permission; } @@ -18,7 +18,7 @@ public RepositoryPermissionRequest(Permission permission) /// /// The permission to grant the team on this repository. /// - public Permission Permission { get; private set; } + public TeamPermissionLegacy Permission { get; private set; } internal string DebuggerDisplay { From 96465ba7caa41211df40cdc4af084f66793e98a3 Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 20:55:57 +0600 Subject: [PATCH 17/39] remove unnecessary SuppressMessage --- Octokit/Models/Common/Permission.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Octokit/Models/Common/Permission.cs b/Octokit/Models/Common/Permission.cs index 6b042fbb31..0f72519fd2 100644 --- a/Octokit/Models/Common/Permission.cs +++ b/Octokit/Models/Common/Permission.cs @@ -8,7 +8,6 @@ namespace Octokit /// /// The permission to grant the team on this repository(Legacy). /// - [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] public enum TeamPermissionLegacy { [Parameter(Value = "pull")] From 2a693845c519cc48e1b74d0352ca68c53681739a Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 24 Jan 2023 20:56:57 +0600 Subject: [PATCH 18/39] remove not null assert on value type --- .../Clients/RepositoryCollaboratorClientTests.cs | 2 -- .../Reactive/ObservableRepositoryCollaboratorClientTests.cs | 2 -- 2 files changed, 4 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs index 380540eac8..486a65e98d 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs @@ -26,8 +26,6 @@ public async Task ReturnsAllCollaborators() var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName); Assert.NotNull(collaborators); Assert.Equal(2, collaborators.Count); - Assert.NotNull(collaborators[0].Permissions); - Assert.NotNull(collaborators[1].Permissions); } } diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs index 4d3a349f1b..ba7a964364 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs @@ -29,8 +29,6 @@ public async Task ReturnsAllCollaborators() Assert.NotNull(collaborators); // this assert fails, added collaborator has to accept the invitation. Assert.Equal(2, collaborators.Count); - Assert.NotNull(collaborators[0].Permissions); - Assert.NotNull(collaborators[1].Permissions); } } From 4f96d0ccdaf29ac6d7c248cb30d321ab844adfab Mon Sep 17 00:00:00 2001 From: notauserx Date: Wed, 25 Jan 2023 10:04:13 +0600 Subject: [PATCH 19/39] remove redundant suppress message --- Octokit/Models/Common/Permission.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Octokit/Models/Common/Permission.cs b/Octokit/Models/Common/Permission.cs index 0f72519fd2..f5d01ace7e 100644 --- a/Octokit/Models/Common/Permission.cs +++ b/Octokit/Models/Common/Permission.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using Octokit.Internal; @@ -23,7 +22,6 @@ public enum TeamPermissionLegacy /// Default: pull /// Can be one of: pull, push /// - [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] public enum TeamPermission { /// From c1ed8614c7a954625b48693090c0d7ec91eff86c Mon Sep 17 00:00:00 2001 From: notauserx Date: Wed, 25 Jan 2023 10:15:43 +0600 Subject: [PATCH 20/39] remove unused suppress message --- Octokit/Models/Response/Collaborator.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Octokit/Models/Response/Collaborator.cs b/Octokit/Models/Response/Collaborator.cs index 772dc25788..abf2d4870e 100644 --- a/Octokit/Models/Response/Collaborator.cs +++ b/Octokit/Models/Response/Collaborator.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; namespace Octokit @@ -74,7 +73,6 @@ public Collaborator(string login, int id, string email, string name, string node public string ReceivedEventsUrl { get; protected set; } - [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "This is what is returned from the API")] public string Type { get; protected set; } public bool SiteAdmin { get; protected set; } From 99fa5132cce5dcacf10cad487bacea807554962d Mon Sep 17 00:00:00 2001 From: notauserx Date: Wed, 25 Jan 2023 10:46:25 +0600 Subject: [PATCH 21/39] update installation permission --- .../Clients/GitHubAppsClientTests.cs | 4 +- .../ObservableGitHubAppsClientTests.cs | 4 +- .../Response/InstallationPermissions.cs | 165 ++++++++++-------- 3 files changed, 101 insertions(+), 72 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs b/Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs index d935d23abc..7a26b714b1 100644 --- a/Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs @@ -71,7 +71,7 @@ public async Task GetsAllInstallations() Assert.Equal(Helper.GitHubAppId, installation.AppId); Assert.NotNull(installation.Account); Assert.NotNull(installation.Permissions); - Assert.Equal(InstallationPermissionLevel.Read, installation.Permissions.Metadata); + Assert.Equal(InstallationReadWritePermissionLevel.Read, installation.Permissions.Metadata); Assert.False(string.IsNullOrEmpty(installation.HtmlUrl)); Assert.NotEqual(0, installation.TargetId); } @@ -101,7 +101,7 @@ public async Task GetsInstallation() Assert.Equal(Helper.GitHubAppId, result.AppId); Assert.NotNull(result.Account); Assert.NotNull(result.Permissions); - Assert.Equal(InstallationPermissionLevel.Read, result.Permissions.Metadata); + Assert.Equal(InstallationReadWritePermissionLevel.Read, result.Permissions.Metadata); Assert.False(string.IsNullOrEmpty(result.HtmlUrl)); Assert.NotEqual(0, result.TargetId); } diff --git a/Octokit.Tests.Integration/Reactive/ObservableGitHubAppsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableGitHubAppsClientTests.cs index 59e6e402cd..f5da91a3de 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableGitHubAppsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableGitHubAppsClientTests.cs @@ -73,7 +73,7 @@ public async Task GetsAllInstallations() Assert.Equal(Helper.GitHubAppId, installation.AppId); Assert.NotNull(installation.Account); Assert.NotNull(installation.Permissions); - Assert.Equal(InstallationPermissionLevel.Read, installation.Permissions.Metadata); + Assert.Equal(InstallationReadWritePermissionLevel.Read, installation.Permissions.Metadata); Assert.False(string.IsNullOrEmpty(installation.HtmlUrl)); Assert.NotEqual(0, installation.TargetId); } @@ -103,7 +103,7 @@ public async Task GetsInstallation() Assert.Equal(Helper.GitHubAppId, result.AppId); Assert.NotNull(result.Account); Assert.NotNull(result.Permissions); - Assert.Equal(InstallationPermissionLevel.Read, result.Permissions.Metadata); + Assert.Equal(InstallationReadWritePermissionLevel.Read, result.Permissions.Metadata); Assert.False(string.IsNullOrEmpty(result.HtmlUrl)); Assert.NotEqual(0, result.TargetId); } diff --git a/Octokit/Models/Response/InstallationPermissions.cs b/Octokit/Models/Response/InstallationPermissions.cs index b45fe0bab2..32328af91f 100644 --- a/Octokit/Models/Response/InstallationPermissions.cs +++ b/Octokit/Models/Response/InstallationPermissions.cs @@ -1,9 +1,11 @@ using System.Diagnostics; -using System.Globalization; using Octokit.Internal; namespace Octokit { + /// + /// The permissions granted to the user-to-server access token. + /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class InstallationPermissions { @@ -11,39 +13,39 @@ public InstallationPermissions() { } 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 + InstallationReadWritePermissionLevel? actions, + InstallationReadWritePermissionLevel? administration, + InstallationReadWritePermissionLevel? checks, + InstallationReadWritePermissionLevel? contents, + InstallationReadWritePermissionLevel? deployments, + InstallationReadWritePermissionLevel? environments, + InstallationReadWritePermissionLevel? issues, + InstallationReadWritePermissionLevel? metadata, + InstallationReadWritePermissionLevel? packages, + InstallationReadWritePermissionLevel? pages, + InstallationReadWritePermissionLevel? pullRequests, + InstallationReadWritePermissionLevel? repositoryAnnouncementBanners, + InstallationReadWritePermissionLevel? repositoryHooks, + InstallationReadWriteAdminPermissionLevel? repositoryProjects, + InstallationReadWritePermissionLevel? secretScanningAlerts, + InstallationReadWritePermissionLevel? secrets, + InstallationReadWritePermissionLevel? securityEvents, + InstallationReadWritePermissionLevel? singleFile, + InstallationReadWritePermissionLevel? statuses, + InstallationReadWritePermissionLevel? vulnerabilityAlerts, + InstallationWritePermissionLevel? workflows, + InstallationReadWritePermissionLevel? members, + InstallationReadWritePermissionLevel? organizationAdministration, + InstallationReadWritePermissionLevel? organizationCustomRoles, + InstallationReadWritePermissionLevel? organizationAnnouncementBanners, + InstallationReadWritePermissionLevel? organizationHooks, + InstallationReadPermissionLevel? organizationPlan, + InstallationReadWriteAdminPermissionLevel? organizationProjects, + InstallationReadWritePermissionLevel? organizationPackages, + InstallationReadWritePermissionLevel? organizationSecrets, + InstallationReadWritePermissionLevel? organizationSelfHostedRunners, + InstallationReadWritePermissionLevel? organizationUserBlocking, + InstallationReadWritePermissionLevel? teamDiscussions ) { Actions = actions; @@ -84,167 +86,167 @@ public InstallationPermissions /// /// The level of permission to grant the access token for GitHub Actions workflows, workflow runs, and artifacts. /// - public StringEnum? Actions { get; private set; } + public StringEnum? Actions { get; private set; } /// /// The level of permission to grant the access token for repository creation, deletion, settings, teams, and collaborators creation. /// - public StringEnum? Administration { get; private set; } + public StringEnum? Administration { get; private set; } /// /// The level of permission to grant the access token for checks on code. /// - public StringEnum? Checks { 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; } + public StringEnum? Contents { get; private set; } /// /// The level of permission to grant the access token for deployments and deployment statuses. /// - public StringEnum? Deployments { get; private set; } + public StringEnum? Deployments { get; private set; } /// /// The level of permission to grant the access token for managing repository environments. /// - public StringEnum? Environments { get; private set; } + 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; } + public StringEnum? Issues { get; private set; } /// /// The level of permission to grant the access token to search repositories, list collaborators, and access repository metadata. /// - public StringEnum? Metadata { get; private set; } + 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; } + 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; } + public StringEnum? Pages { get; private set; } /// /// 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; } + public StringEnum? PullRequests { get; private set; } /// /// The level of permission to grant the access token to view and manage announcement banners for a repository. /// - public StringEnum? RepositoryAnnouncementBanners { get; private set; } + public StringEnum? RepositoryAnnouncementBanners { get; private set; } /// /// The level of permission to grant the access token to manage the post-receive hooks for a repository. /// - public StringEnum? RepositoryHooks { get; private set; } + public StringEnum? RepositoryHooks { get; private set; } /// /// The level of permission to grant the access token to manage repository projects, columns, and cards. /// - public StringEnum? RepositoryProjects { get; private set; } + public StringEnum? RepositoryProjects { get; private set; } /// /// The level of permission to grant the access token to view and manage secret scanning alerts. /// - public StringEnum? SecretScanningAlerts { get; private set; } + public StringEnum? SecretScanningAlerts { get; private set; } /// /// The level of permission to grant the access token to manage repository secrets. /// - public StringEnum? Secrets { get; private set; } + 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; } + 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; } + public StringEnum? SingleFile { get; private set; } /// /// The level of permission to grant the access token for commit statuses. /// - public StringEnum? Statuses { get; private set; } + 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; } + 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; } + 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; } + public StringEnum? Members { get; private set; } /// /// The level of permission to grant the access token to manage access to an organization. /// - public StringEnum? OrganizationAdministration { get; private set; } + 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; } + 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; } + 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; } + 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; } + 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; } + public StringEnum? OrganizationProjects { get; private set; } /// /// The level of permission to grant the access token for organization packages published to GitHub Packages. /// - public StringEnum? OrganizationPackages { get; private set; } + 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; } + 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; } + 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; } + 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; } + public StringEnum? TeamDiscussions { get; private set; } internal string DebuggerDisplay { @@ -252,7 +254,7 @@ internal string DebuggerDisplay } } - public enum InstallationPermissionLevel + public enum InstallationReadWritePermissionLevel { [Parameter(Value = "read")] Read, @@ -260,4 +262,31 @@ public enum InstallationPermissionLevel [Parameter(Value = "write")] Write } + + // TODO :: find a better name for this enum + public enum InstallationReadWriteAdminPermissionLevel + { + [Parameter(Value = "read")] + Read, + + [Parameter(Value = "write")] + Write, + + [Parameter(Value = "admin")] + Admin + } + + // TODO :: find a better name for this enum + public enum InstallationWritePermissionLevel + { + [Parameter(Value = "write")] + Write + } + + // TODO :: find a better name for this enum + public enum InstallationReadPermissionLevel + { + [Parameter(Value = "read")] + Read + } } From d338c33d14760bf76034a0b9817c1b0a24825f10 Mon Sep 17 00:00:00 2001 From: notauserx Date: Wed, 25 Jan 2023 10:49:38 +0600 Subject: [PATCH 22/39] move app installation permission enums to permission file --- Octokit/Models/Common/Permission.cs | 30 +++++++++++++++ .../Response/InstallationPermissions.cs | 37 ------------------- 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/Octokit/Models/Common/Permission.cs b/Octokit/Models/Common/Permission.cs index f5d01ace7e..c31c93320c 100644 --- a/Octokit/Models/Common/Permission.cs +++ b/Octokit/Models/Common/Permission.cs @@ -4,6 +4,36 @@ namespace Octokit { + public enum InstallationReadWritePermissionLevel + { + [Parameter(Value = "read")] + Read, + [Parameter(Value = "write")] + Write + } + + public enum InstallationReadWriteAdminPermissionLevel + { + [Parameter(Value = "read")] + Read, + [Parameter(Value = "write")] + Write, + [Parameter(Value = "admin")] + Admin + } + + public enum InstallationWritePermissionLevel + { + [Parameter(Value = "write")] + Write + } + + public enum InstallationReadPermissionLevel + { + [Parameter(Value = "read")] + Read + } + /// /// The permission to grant the team on this repository(Legacy). /// diff --git a/Octokit/Models/Response/InstallationPermissions.cs b/Octokit/Models/Response/InstallationPermissions.cs index 32328af91f..d97693d059 100644 --- a/Octokit/Models/Response/InstallationPermissions.cs +++ b/Octokit/Models/Response/InstallationPermissions.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using Octokit.Internal; namespace Octokit { @@ -253,40 +252,4 @@ internal string DebuggerDisplay 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}"; } } - - public enum InstallationReadWritePermissionLevel - { - [Parameter(Value = "read")] - Read, - - [Parameter(Value = "write")] - Write - } - - // TODO :: find a better name for this enum - public enum InstallationReadWriteAdminPermissionLevel - { - [Parameter(Value = "read")] - Read, - - [Parameter(Value = "write")] - Write, - - [Parameter(Value = "admin")] - Admin - } - - // TODO :: find a better name for this enum - public enum InstallationWritePermissionLevel - { - [Parameter(Value = "write")] - Write - } - - // TODO :: find a better name for this enum - public enum InstallationReadPermissionLevel - { - [Parameter(Value = "read")] - Read - } } From 303aa8fa0d9ca390d21450533e3aeb82c22b5593 Mon Sep 17 00:00:00 2001 From: notauserx Date: Wed, 25 Jan 2023 11:13:01 +0600 Subject: [PATCH 23/39] use string interpolation in debugger display --- Octokit/Models/Response/Collaborator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Response/Collaborator.cs b/Octokit/Models/Response/Collaborator.cs index abf2d4870e..e5e2d14d0d 100644 --- a/Octokit/Models/Response/Collaborator.cs +++ b/Octokit/Models/Response/Collaborator.cs @@ -86,7 +86,7 @@ internal string DebuggerDisplay get { return string.Format(CultureInfo.InvariantCulture, - "Collaborator: Id: {0} Login: {1}", Id, Login); + $"Collaborator: Id: {Id} Login: {Login}"); } } } From 8a166b34e7b376c3b83bce19aa8de4da645b3a8c Mon Sep 17 00:00:00 2001 From: notauserx Date: Wed, 25 Jan 2023 11:21:49 +0600 Subject: [PATCH 24/39] add missing properties from constructor params --- Octokit/Models/Response/Installation.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Octokit/Models/Response/Installation.cs b/Octokit/Models/Response/Installation.cs index 98e002630d..af64833fc0 100644 --- a/Octokit/Models/Response/Installation.cs +++ b/Octokit/Models/Response/Installation.cs @@ -19,6 +19,8 @@ public Installation() { } public Installation(long id, User account, string accessTokenUrl, string repositoriesUrl, string htmlUrl, long appId, long targetId, AccountType targetType, InstallationPermissions permissions, IReadOnlyList events, string singleFileName, string repositorySelection) : base(id) { Account = account; + AccessTokensUrl = accessTokenUrl; + RepositoriesUrl = repositoriesUrl; HtmlUrl = htmlUrl; AppId = appId; TargetId = targetId; @@ -34,6 +36,10 @@ public Installation(long id, User account, string accessTokenUrl, string reposit /// public User Account { get; private set; } + public string AccessTokensUrl { get; private set; } + + public string RepositoriesUrl { get; private set; } + /// /// The URL to view the Installation on GitHub. /// From a4ee06b6cee904e83c421335501007b43cdabb3c Mon Sep 17 00:00:00 2001 From: notauserx Date: Wed, 25 Jan 2023 11:29:05 +0600 Subject: [PATCH 25/39] rename param to pass convention tests --- Octokit/Models/Response/Installation.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Models/Response/Installation.cs b/Octokit/Models/Response/Installation.cs index af64833fc0..1fcdaf5462 100644 --- a/Octokit/Models/Response/Installation.cs +++ b/Octokit/Models/Response/Installation.cs @@ -16,10 +16,10 @@ public class Installation : InstallationId { public Installation() { } - public Installation(long id, User account, string accessTokenUrl, string repositoriesUrl, string htmlUrl, long appId, long targetId, AccountType targetType, InstallationPermissions permissions, IReadOnlyList events, string singleFileName, string repositorySelection) : base(id) + public Installation(long id, User account, string accessTokensUrl, string repositoriesUrl, string htmlUrl, long appId, long targetId, AccountType targetType, InstallationPermissions permissions, IReadOnlyList events, string singleFileName, string repositorySelection) : base(id) { Account = account; - AccessTokensUrl = accessTokenUrl; + AccessTokensUrl = accessTokensUrl; RepositoriesUrl = repositoriesUrl; HtmlUrl = htmlUrl; AppId = appId; From 52806b47952e6aa33efbbe0e327a88674a80e435 Mon Sep 17 00:00:00 2001 From: notauserx Date: Wed, 25 Jan 2023 11:34:55 +0600 Subject: [PATCH 26/39] update doc reference --- Octokit/Models/Response/Installation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Response/Installation.cs b/Octokit/Models/Response/Installation.cs index 1fcdaf5462..b4c5341407 100644 --- a/Octokit/Models/Response/Installation.cs +++ b/Octokit/Models/Response/Installation.cs @@ -9,7 +9,7 @@ namespace Octokit /// Represents an application installation. /// /// - /// For more information see https://developer.github.com/v3/apps/#find-installations + /// For more information see https://docs.github.com/en/rest/apps/installations?apiVersion=2022-11-28#list-app-installations-accessible-to-the-user-access-token /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class Installation : InstallationId From b29a4bff89bc8b9ff706b4ac2f077b71ec4e1346 Mon Sep 17 00:00:00 2001 From: notauserx Date: Sun, 12 Feb 2023 20:00:11 +0600 Subject: [PATCH 27/39] fix type for property --- Octokit/Models/Request/RepositoryCollaboratorListRequest.cs | 2 ++ Octokit/Models/Response/Collaborator.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Octokit/Models/Request/RepositoryCollaboratorListRequest.cs b/Octokit/Models/Request/RepositoryCollaboratorListRequest.cs index 6f5a8a4f4c..bb034e60cb 100644 --- a/Octokit/Models/Request/RepositoryCollaboratorListRequest.cs +++ b/Octokit/Models/Request/RepositoryCollaboratorListRequest.cs @@ -26,6 +26,8 @@ public RepositoryCollaboratorListRequest() /// public CollaboratorAffiliation Affiliation { get; set; } + public CollaboratorPermission? Permission { get; set; } + internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Affiliation: {0}", Affiliation); } diff --git a/Octokit/Models/Response/Collaborator.cs b/Octokit/Models/Response/Collaborator.cs index e5e2d14d0d..d0b501b68d 100644 --- a/Octokit/Models/Response/Collaborator.cs +++ b/Octokit/Models/Response/Collaborator.cs @@ -8,7 +8,7 @@ public class Collaborator { public Collaborator() { } - public Collaborator(string login, int id, string email, string name, string nodeId, string avatarUrl, string gravatarUrl, string url, string htmlUrl, string followersUrl, string followingUrl, string gistsUrl, string type, string starredUrl, string subscriptionsUrl, string organizationsUrl, string reposUrl, string eventsUrl, string receivedEventsUrl, bool siteAdmin, CollaboratorPermission permissions, string roleName) + public Collaborator(string login, int id, string email, string name, string nodeId, string avatarUrl, string gravatarUrl, string url, string htmlUrl, string followersUrl, string followingUrl, string gistsUrl, string type, string starredUrl, string subscriptionsUrl, string organizationsUrl, string reposUrl, string eventsUrl, string receivedEventsUrl, bool siteAdmin, CollaboratorPermissions permissions, string roleName) { Login = login; Id = id; @@ -77,7 +77,7 @@ public Collaborator(string login, int id, string email, string name, string node public bool SiteAdmin { get; protected set; } - public StringEnum Permissions { get; protected set; } + public CollaboratorPermissions Permissions { get; protected set; } public string RoleName { get; protected set; } From 4acadfd6689e2f20fd5a670815fc5740c6143986 Mon Sep 17 00:00:00 2001 From: notauserx Date: Sun, 12 Feb 2023 20:33:36 +0600 Subject: [PATCH 28/39] update model for RepositoryCollaboratorListResponse --- Octokit/Models/Common/Permission.cs | 16 +++++++++------- .../Request/RepositoryCollaboratorListRequest.cs | 5 ++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Octokit/Models/Common/Permission.cs b/Octokit/Models/Common/Permission.cs index c31c93320c..c468cc96ce 100644 --- a/Octokit/Models/Common/Permission.cs +++ b/Octokit/Models/Common/Permission.cs @@ -86,14 +86,16 @@ public enum InvitationPermissionType public enum CollaboratorPermission { + [Parameter(Value = "pull")] + Pull, + [Parameter(Value = "triage")] + Triage, + [Parameter(Value = "push")] + Push, + [Parameter(Value = "maintain")] + Maintain, [Parameter(Value = "admin")] - Admin, - [Parameter(Value = "write")] - Write, - [Parameter(Value = "read")] - Read, - [Parameter(Value = "none")] - None + Admin } /// diff --git a/Octokit/Models/Request/RepositoryCollaboratorListRequest.cs b/Octokit/Models/Request/RepositoryCollaboratorListRequest.cs index bb034e60cb..d05537680c 100644 --- a/Octokit/Models/Request/RepositoryCollaboratorListRequest.cs +++ b/Octokit/Models/Request/RepositoryCollaboratorListRequest.cs @@ -26,11 +26,14 @@ public RepositoryCollaboratorListRequest() /// public CollaboratorAffiliation Affiliation { get; set; } + /// + /// Filter collaborators by the permissions they have on the repository. If not specified, all collaborators will be returned. + /// public CollaboratorPermission? Permission { get; set; } internal string DebuggerDisplay { - get { return string.Format(CultureInfo.InvariantCulture, "Affiliation: {0}", Affiliation); } + get { return string.Format(CultureInfo.InvariantCulture, $"Affiliation: {Affiliation} Permission: {Permission}"); } } } From 47ac6dfcfa4f785ed8dfd7eb35f1d2155a9deb8b Mon Sep 17 00:00:00 2001 From: notauserx Date: Sun, 12 Feb 2023 20:35:18 +0600 Subject: [PATCH 29/39] rename file to match classname --- ...ollaboratorPermission.cs => CollaboratorPermissionResponse.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Octokit/Models/Response/{CollaboratorPermission.cs => CollaboratorPermissionResponse.cs} (100%) diff --git a/Octokit/Models/Response/CollaboratorPermission.cs b/Octokit/Models/Response/CollaboratorPermissionResponse.cs similarity index 100% rename from Octokit/Models/Response/CollaboratorPermission.cs rename to Octokit/Models/Response/CollaboratorPermissionResponse.cs From 54381f38ae432d43703d2aef5a9183dd65788109 Mon Sep 17 00:00:00 2001 From: notauserx Date: Sun, 12 Feb 2023 20:42:51 +0600 Subject: [PATCH 30/39] use expression body for debugger display --- Octokit/Models/Common/Permission.cs | 16 ++-------------- .../Request/RepositoryCollaboratorListRequest.cs | 5 +---- Octokit/Models/Response/Collaborator.cs | 8 +------- Octokit/Models/Response/Installation.cs | 5 +---- .../Models/Response/InstallationPermissions.cs | 5 +---- Octokit/Models/Response/RepositoryInvitation.cs | 8 +------- 6 files changed, 7 insertions(+), 40 deletions(-) diff --git a/Octokit/Models/Common/Permission.cs b/Octokit/Models/Common/Permission.cs index c468cc96ce..4b2ea2d17a 100644 --- a/Octokit/Models/Common/Permission.cs +++ b/Octokit/Models/Common/Permission.cs @@ -149,14 +149,8 @@ public TeamRepositoryPermissions(bool pull, bool triage, bool push, bool maintai /// public bool Admin { get; private set; } - internal string DebuggerDisplay - { - get - { - return string.Format(CultureInfo.InvariantCulture, + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, $"Permissions: Pull: {Pull}, Triage: {Triage}, Push: {Push}, Maintain: {Maintain}, Admin: {Admin}"); - } - } } /// @@ -185,13 +179,7 @@ public CollaboratorPermissions(bool pull, bool? triage, bool push, bool? maintai public bool Admin { get; private set; } - internal string DebuggerDisplay - { - get - { - return string.Format(CultureInfo.InvariantCulture, + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, $"Permissions: Pull: {Pull}, Triage: {Triage}, Push: {Push}, Maintain: {Maintain}, Admin: {Admin}"); - } - } } } diff --git a/Octokit/Models/Request/RepositoryCollaboratorListRequest.cs b/Octokit/Models/Request/RepositoryCollaboratorListRequest.cs index d05537680c..6cc11e6f48 100644 --- a/Octokit/Models/Request/RepositoryCollaboratorListRequest.cs +++ b/Octokit/Models/Request/RepositoryCollaboratorListRequest.cs @@ -31,10 +31,7 @@ public RepositoryCollaboratorListRequest() /// public CollaboratorPermission? Permission { get; set; } - internal string DebuggerDisplay - { - get { return string.Format(CultureInfo.InvariantCulture, $"Affiliation: {Affiliation} Permission: {Permission}"); } - } + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, $"Affiliation: {Affiliation} Permission: {Permission}"); } /// diff --git a/Octokit/Models/Response/Collaborator.cs b/Octokit/Models/Response/Collaborator.cs index d0b501b68d..269fcc2d53 100644 --- a/Octokit/Models/Response/Collaborator.cs +++ b/Octokit/Models/Response/Collaborator.cs @@ -81,13 +81,7 @@ public Collaborator(string login, int id, string email, string name, string node public string RoleName { get; protected set; } - internal string DebuggerDisplay - { - get - { - return string.Format(CultureInfo.InvariantCulture, + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, $"Collaborator: Id: {Id} Login: {Login}"); - } - } } } \ No newline at end of file diff --git a/Octokit/Models/Response/Installation.cs b/Octokit/Models/Response/Installation.cs index b4c5341407..99d4e372f9 100644 --- a/Octokit/Models/Response/Installation.cs +++ b/Octokit/Models/Response/Installation.cs @@ -80,10 +80,7 @@ public Installation(long id, User account, string accessTokensUrl, string reposi /// public StringEnum RepositorySelection { get; private set; } - internal new string DebuggerDisplay - { - get { return string.Format(CultureInfo.InvariantCulture, "Id: {0} AppId: {1}", Id, AppId); } - } + internal new string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Id: {0} AppId: {1}", Id, AppId); } public enum InstallationRepositorySelection diff --git a/Octokit/Models/Response/InstallationPermissions.cs b/Octokit/Models/Response/InstallationPermissions.cs index d97693d059..5e4baf3803 100644 --- a/Octokit/Models/Response/InstallationPermissions.cs +++ b/Octokit/Models/Response/InstallationPermissions.cs @@ -247,9 +247,6 @@ public InstallationPermissions /// public StringEnum? TeamDiscussions { get; private set; } - internal string DebuggerDisplay - { - 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}"; - } + internal string DebuggerDisplay => $"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/RepositoryInvitation.cs b/Octokit/Models/Response/RepositoryInvitation.cs index 2a9ed22fdf..bc76e303f4 100644 --- a/Octokit/Models/Response/RepositoryInvitation.cs +++ b/Octokit/Models/Response/RepositoryInvitation.cs @@ -61,13 +61,7 @@ public RepositoryInvitation(int id, string nodeId, Repository repository, User i public string HtmlUrl { get; private set; } - internal string DebuggerDisplay - { - get - { - return string.Format(CultureInfo.InvariantCulture, + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Repository Invitation: Id: {0} Permissions: {1}", Id, Permissions); - } - } } } From 9799f84808ab3a452eced6638bed7c3216b4a4fd Mon Sep 17 00:00:00 2001 From: notauserx Date: Sun, 12 Feb 2023 20:49:28 +0600 Subject: [PATCH 31/39] clean up model --- Octokit/Models/Request/CollaboratorRequest.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Octokit/Models/Request/CollaboratorRequest.cs b/Octokit/Models/Request/CollaboratorRequest.cs index 74db378c8e..ffb6e6d875 100644 --- a/Octokit/Models/Request/CollaboratorRequest.cs +++ b/Octokit/Models/Request/CollaboratorRequest.cs @@ -9,9 +9,9 @@ public class CollaboratorRequest /// /// Used to set the permission for a collaborator. /// - public CollaboratorRequest(string permissions) + public CollaboratorRequest(string permission) { - Permission = permissions; + Permission = permission; } /// @@ -22,12 +22,6 @@ public CollaboratorRequest(string permissions) /// public string Permission { get; private set; } - internal string DebuggerDisplay - { - get - { - return string.Format(CultureInfo.InvariantCulture, "Permission: {0}", Permission); - } - } + internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, $"Permission: {Permission}"); } } From e448c0fb37c9dc73a4e6b089a80055109967f7e0 Mon Sep 17 00:00:00 2001 From: notauserx Date: Mon, 13 Feb 2023 10:34:44 +0600 Subject: [PATCH 32/39] move xunit import statement --- .../Clients/RepositoryCollaboratorClientTests.cs | 2 +- .../Reactive/ObservableRepositoryCollaboratorClientTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs index 486a65e98d..a385e3232f 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs @@ -2,8 +2,8 @@ using System.Threading.Tasks; using Octokit; using Octokit.Tests.Integration; -using Xunit; using Octokit.Tests.Integration.Helpers; +using Xunit; public class RepositoryCollaboratorClientTests { diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs index ba7a964364..668b4fabb7 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs @@ -4,8 +4,8 @@ using Octokit; using Octokit.Reactive; using Octokit.Tests.Integration; -using Xunit; using Octokit.Tests.Integration.Helpers; +using Xunit; public class ObservableRepositoryCollaboratorClientTests { From 180356e7c199e2b97ba72950ef3649608c873845 Mon Sep 17 00:00:00 2001 From: notauserx Date: Mon, 13 Feb 2023 10:50:24 +0600 Subject: [PATCH 33/39] fix integration tests for TheGetAllMethod --- .../RepositoryCollaboratorClientTests.cs | 45 ++++++------------- ...rvableRepositoryCollaboratorClientTests.cs | 24 +++------- 2 files changed, 21 insertions(+), 48 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs index a385e3232f..38d39901ae 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs @@ -19,13 +19,10 @@ public async Task ReturnsAllCollaborators() { var fixture = github.Repository.Collaborator; - // add a collaborator - // this sends a repository invitation, the collaborator still has to accept the invitation. - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); - var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName); + Assert.NotNull(collaborators); - Assert.Equal(2, collaborators.Count); + Assert.Equal(1, collaborators.Count); } } @@ -39,12 +36,10 @@ public async Task ReturnsAllCollaboratorsWithRepositoryId() { var fixture = github.Repository.Collaborator; - // add a collaborator - await fixture.Add(context.Repository.Id, "m-zuber-octokit-integration-tests"); - var collaborators = await fixture.GetAll(context.Repository.Id); + Assert.NotNull(collaborators); - Assert.Equal(2, collaborators.Count); + Assert.Equal(1, collaborators.Count); } } @@ -58,9 +53,6 @@ public async Task ReturnsCorrectCountOfCollaboratorsWithoutStart() { var fixture = github.Repository.Collaborator; - // add some collaborators - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); - var options = new ApiOptions { PageSize = 1, @@ -68,6 +60,7 @@ public async Task ReturnsCorrectCountOfCollaboratorsWithoutStart() }; var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, options); + Assert.NotNull(collaborators); Assert.Equal(1, collaborators.Count); } @@ -83,9 +76,6 @@ public async Task ReturnsCorrectCountOfCollaboratorsWithoutStartAndRepositoryId( { var fixture = github.Repository.Collaborator; - // add some collaborators - await fixture.Add(context.Repository.Id, "m-zuber-octokit-integration-tests"); - var options = new ApiOptions { PageSize = 1, @@ -93,6 +83,7 @@ public async Task ReturnsCorrectCountOfCollaboratorsWithoutStartAndRepositoryId( }; var collaborators = await fixture.GetAll(context.Repository.Id, options); + Assert.NotNull(collaborators); Assert.Equal(1, collaborators.Count); } @@ -108,9 +99,6 @@ public async Task ReturnsCorrectCountOfCollaboratorsWithStart() { var fixture = github.Repository.Collaborator; - // add some collaborators - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); - var options = new ApiOptions { PageSize = 1, @@ -119,8 +107,9 @@ public async Task ReturnsCorrectCountOfCollaboratorsWithStart() }; var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, options); + Assert.NotNull(collaborators); - Assert.Equal(1, collaborators.Count); + Assert.Equal(0, collaborators.Count); } } @@ -134,9 +123,6 @@ public async Task ReturnsCorrectCountOfCollaboratorsWithStartAndRepositoryId() { var fixture = github.Repository.Collaborator; - // add some collaborators - await fixture.Add(context.Repository.Id, "m-zuber-octokit-integration-tests"); - var options = new ApiOptions { PageSize = 1, @@ -145,8 +131,9 @@ public async Task ReturnsCorrectCountOfCollaboratorsWithStartAndRepositoryId() }; var collaborators = await fixture.GetAll(context.Repository.Id, options); + Assert.NotNull(collaborators); - Assert.Equal(1, collaborators.Count); + Assert.Equal(0, collaborators.Count); } } @@ -160,9 +147,6 @@ public async Task ReturnsDistinctResultsBasedOnStartPage() { var fixture = github.Repository.Collaborator; - // add some collaborators - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); - var startOptions = new ApiOptions { PageSize = 1, @@ -180,7 +164,8 @@ public async Task ReturnsDistinctResultsBasedOnStartPage() var secondPage = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, skipStartOptions); - Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.Equal(1, firstPage.Count); + Assert.Equal(0, secondPage.Count); } } @@ -194,9 +179,6 @@ public async Task ReturnsDistinctResultsBasedOnStartPageWithRepositoryId() { var fixture = github.Repository.Collaborator; - // add some collaborators - await fixture.Add(context.Repository.Id, "m-zuber-octokit-integration-tests"); - var startOptions = new ApiOptions { PageSize = 1, @@ -214,7 +196,8 @@ public async Task ReturnsDistinctResultsBasedOnStartPageWithRepositoryId() var secondPage = await fixture.GetAll(context.Repository.Id, skipStartOptions); - Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.Equal(1, firstPage.Count); + Assert.Equal(0, secondPage.Count); } } } diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs index 668b4fabb7..93e7ee26d9 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs @@ -21,14 +21,10 @@ public async Task ReturnsAllCollaborators() { var fixture = new ObservableRepoCollaboratorsClient(github); - // add a collaborator - // this sends a repository invitation - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); - var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName).ToList(); + Assert.NotNull(collaborators); - // this assert fails, added collaborator has to accept the invitation. - Assert.Equal(2, collaborators.Count); + Assert.Equal(1, collaborators.Count); } } @@ -42,9 +38,6 @@ public async Task ReturnsCorrectCountOfCollaboratorsWithoutStart() { var fixture = new ObservableRepoCollaboratorsClient(github); - // add some collaborators - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); - var options = new ApiOptions { PageSize = 1, @@ -52,6 +45,7 @@ public async Task ReturnsCorrectCountOfCollaboratorsWithoutStart() }; var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, options).ToList(); + Assert.NotNull(collaborators); Assert.Equal(1, collaborators.Count); } @@ -67,9 +61,6 @@ public async Task ReturnsCorrectCountOfCollaboratorsWithStart() { var fixture = new ObservableRepoCollaboratorsClient(github); - // add some collaborators - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); - var options = new ApiOptions { PageSize = 1, @@ -78,8 +69,9 @@ public async Task ReturnsCorrectCountOfCollaboratorsWithStart() }; var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, options).ToList(); + Assert.NotNull(collaborators); - Assert.Equal(1, collaborators.Count); + Assert.Equal(0, collaborators.Count); } } @@ -93,9 +85,6 @@ public async Task ReturnsDistinctResultsBasedOnStartPage() { var fixture = new ObservableRepoCollaboratorsClient(github); - // add some collaborators - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); - var startOptions = new ApiOptions { PageSize = 1, @@ -113,7 +102,8 @@ public async Task ReturnsDistinctResultsBasedOnStartPage() var secondPage = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, skipStartOptions).ToList(); - Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.Equal(1, firstPage.Count); + Assert.Equal(0, secondPage.Count); } } } From 8ca4b3fa858e63146b5e88ab7cf2f28bddb081b7 Mon Sep 17 00:00:00 2001 From: notauserx Date: Mon, 13 Feb 2023 11:57:46 +0600 Subject: [PATCH 34/39] update tests for IsCollaboratorMethod --- .../RepositoryCollaboratorClientTests.cs | 28 ++++++------------- ...rvableRepositoryCollaboratorClientTests.cs | 5 +--- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs index 38d39901ae..3c7a8bbe7f 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs @@ -214,10 +214,7 @@ public async Task ReturnsTrueIfUserIsCollaborator() { var fixture = github.Repository.Collaborator; - // add a collaborator - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); - - var isCollab = await fixture.IsCollaborator(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); + var isCollab = await fixture.IsCollaborator(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner); Assert.True(isCollab); } @@ -233,10 +230,7 @@ public async Task ReturnsTrueIfUserIsCollaboratorWithRepositoryId() { var fixture = github.Repository.Collaborator; - // add a collaborator - await fixture.Add(context.Repository.Id, "m-zuber-octokit-integration-tests"); - - var isCollab = await fixture.IsCollaborator(context.Repository.Id, "m-zuber-octokit-integration-tests"); + var isCollab = await fixture.IsCollaborator(context.Repository.Id, context.RepositoryOwner); Assert.True(isCollab); } @@ -277,9 +271,8 @@ public async Task ReturnsReadPermissionForNonCollaboratorWithRepositoryId() } } - // TODO :: This test is failing in current main, should I remove this test? [IntegrationTest] - public async Task ReturnsWritePermissionForCollaborator() + public async Task ReturnsWritePermissionForCollaboratorInvitation() { var github = Helper.GetAuthenticatedClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); @@ -289,18 +282,15 @@ public async Task ReturnsWritePermissionForCollaborator() var fixture = github.Repository.Collaborator; // add a collaborator - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - - var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); + var invitation = await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1", new CollaboratorRequest("write")); - Assert.Equal("write", permission.Permission); + Assert.Equal(InvitationPermissionType.Write, invitation.Permissions); } } - // TODO :: This test is failing in current main, should I remove this test? [IntegrationTest] - public async Task ReturnsWritePermissionForCollaboratorWithRepositoryId() + public async Task ReturnsWritePermissionForCollaboratorInvitationWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); @@ -310,11 +300,9 @@ public async Task ReturnsWritePermissionForCollaboratorWithRepositoryId() var fixture = github.Repository.Collaborator; // add a collaborator - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - - var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); + var invitation = await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1", new CollaboratorRequest("write")); - Assert.Equal("write", permission.Permission); + Assert.Equal(InvitationPermissionType.Write, invitation.Permissions); } } diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs index 93e7ee26d9..6df907cdda 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs @@ -120,10 +120,7 @@ public async Task ReturnsTrueIfUserIsCollaborator() { var fixture = new ObservableRepoCollaboratorsClient(github); - // add a collaborator - fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); - - var isCollab = await fixture.IsCollaborator(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); + var isCollab = await fixture.IsCollaborator(context.RepositoryOwner, context.RepositoryName, context.RepositoryOwner); Assert.True(isCollab); } From 15b321a7c8379c921918817858527f4819fb515e Mon Sep 17 00:00:00 2001 From: notauserx Date: Mon, 13 Feb 2023 12:16:14 +0600 Subject: [PATCH 35/39] skip delete tests --- .../Clients/RepositoryCollaboratorClientTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs index 3c7a8bbe7f..b03603c82e 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs @@ -383,7 +383,7 @@ public async Task ReturnsNonePermissionForPrivateRepositoryWithRepositoryId() public class TheDeleteMethod { - [IntegrationTest] + [Fact(Skip = "Adding a collaborator sends an invitation, need to figure out a way to test the remove method.")] public async Task CheckDeleteMethod() { var github = Helper.GetAuthenticatedClient(); @@ -405,7 +405,7 @@ public async Task CheckDeleteMethod() } } - [IntegrationTest] + [Fact(Skip = "Adding a collaborator sends an invitation, need to figure out a way to test the remove method.")] public async Task CheckDeleteMethodWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); From dbd4578808957ef0456459ef10cb2fce939c8887 Mon Sep 17 00:00:00 2001 From: notauserx Date: Mon, 13 Feb 2023 12:23:51 +0600 Subject: [PATCH 36/39] update tests for TheReviewPermissionMethod --- ...bservableRepositoryCollaboratorClientTests.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs index 6df907cdda..2fad13688c 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCollaboratorClientTests.cs @@ -161,7 +161,7 @@ public async Task ReturnsReadPermissionForNonCollaboratorWithRepositoryId() } [IntegrationTest] - public async Task ReturnsWritePermissionForCollaborator() + public async Task ReturnsWritePermissionForCollaboratorInvitation() { var github = Helper.GetAuthenticatedClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); @@ -171,16 +171,14 @@ public async Task ReturnsWritePermissionForCollaborator() var fixture = new ObservableRepoCollaboratorsClient(github); // add a collaborator - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); + var invitation = await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1", new CollaboratorRequest("write")); - var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - - Assert.Equal("write", permission.Permission); + Assert.Equal(InvitationPermissionType.Write, invitation.Permissions); } } [IntegrationTest] - public async Task ReturnsWritePermissionForCollaboratorWithRepositoryId() + public async Task ReturnsWritePermissionForCollaboratorInvitationWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); @@ -190,11 +188,9 @@ public async Task ReturnsWritePermissionForCollaboratorWithRepositoryId() var fixture = new ObservableRepoCollaboratorsClient(github); // add a collaborator - await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1"); - - var permission = await fixture.ReviewPermission(context.RepositoryId, "octokitnet-test1"); + var invitation = await fixture.Add(context.RepositoryOwner, context.RepositoryName, "octokitnet-test1", new CollaboratorRequest("write")); - Assert.Equal("write", permission.Permission); + Assert.Equal(InvitationPermissionType.Write, invitation.Permissions); } } From 5629bc335496ab4f85c95da031285ce849ad16b9 Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 14 Feb 2023 12:09:29 +0600 Subject: [PATCH 37/39] add test for permission filter --- .../Clients/RepoCollaboratorsClientTests.cs | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) diff --git a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs index ef4f160e36..a97a491a8f 100644 --- a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs +++ b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs @@ -116,6 +116,88 @@ public void RequestsCorrectUrlWithCollaboratorFilter() Args.ApiOptions); } + [Fact] + public void RequestsCorrectUrlWithPermissionFilter() + { + var connection = Substitute.For(); + var client = new RepoCollaboratorsClient(connection); + + var request = new RepositoryCollaboratorListRequest(); + + client.GetAll("owner", "test", request); + + connection.Received() + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), + Arg.Is>(d => !d.ContainsKey("permission")), + Args.ApiOptions); + + request = new RepositoryCollaboratorListRequest + { + Permission = CollaboratorPermission.Admin + }; + + client.GetAll("owner", "test", request); + + connection.Received() + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), + Arg.Is>(d => d["permission"] == "admin"), + Args.ApiOptions); + + request = new RepositoryCollaboratorListRequest + { + Permission = CollaboratorPermission.Maintain + }; + + client.GetAll("owner", "test", request); + + connection.Received() + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), + Arg.Is>(d => d["permission"] == "maintain"), + Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithCollaboratorFilterAndPermissionFilter() + { + var connection = Substitute.For(); + var client = new RepoCollaboratorsClient(connection); + + var request = new RepositoryCollaboratorListRequest(); + + client.GetAll("owner", "test", request); + + connection.Received() + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), + Arg.Is>(d => d["affiliation"] == "all" && !d.ContainsKey("permission")), + Args.ApiOptions); + + request = new RepositoryCollaboratorListRequest + { + Affiliation = CollaboratorAffiliation.Direct, + Permission = CollaboratorPermission.Admin + }; + + client.GetAll("owner", "test", request); + + connection.Received() + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), + Arg.Is>(d => d["affiliation"] == "direct" && d["permission"] == "admin"), + Args.ApiOptions); + + request = new RepositoryCollaboratorListRequest + { + Affiliation = CollaboratorAffiliation.Outside, + Permission = CollaboratorPermission.Pull + }; + + client.GetAll("owner", "test", request); + + connection.Received() + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/test/collaborators"), + Arg.Is>(d => d["affiliation"] == "outside" && d["permission"] == "pull"), + Args.ApiOptions); + } + [Fact] public void RequestsCorrectUrlWithApiOptionsAndRepositoryId() { @@ -181,6 +263,94 @@ public void RequestsCorrectUrlWithCollaboratorFilterAndRepositoryId() Args.ApiOptions); } + [Fact] + public void RequestsCorrectUrlWithPermissionFilterAndRepositoryId() + { + var connection = Substitute.For(); + var client = new RepoCollaboratorsClient(connection); + + var request = new RepositoryCollaboratorListRequest(); + + client.GetAll(1, request); + + connection.Received() + .GetAll( + Arg.Is(u => u.ToString() == "repositories/1/collaborators"), + Arg.Is>(d => !d.ContainsKey("permission")), + Args.ApiOptions); + + request = new RepositoryCollaboratorListRequest + { + Permission = CollaboratorPermission.Triage + }; + + client.GetAll(1, request); + + connection.Received() + .GetAll( + Arg.Is(u => u.ToString() == "repositories/1/collaborators"), + Arg.Is>(d => d["permission"] == "triage"), + Args.ApiOptions); + + request = new RepositoryCollaboratorListRequest + { + Permission = CollaboratorPermission.Push + }; + + client.GetAll(1, request); + + connection.Received() + .GetAll( + Arg.Is(u => u.ToString() == "repositories/1/collaborators"), + Arg.Is>(d => d["permission"] == "push"), + Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithCollaboratorFilterPermissionFilterAndRepositoryId() + { + var connection = Substitute.For(); + var client = new RepoCollaboratorsClient(connection); + + var request = new RepositoryCollaboratorListRequest(); + + client.GetAll(1, request); + + connection.Received() + .GetAll( + Arg.Is(u => u.ToString() == "repositories/1/collaborators"), + Arg.Is>(d => d["affiliation"] == "all" && !d.ContainsKey("permission")), + Args.ApiOptions); + + request = new RepositoryCollaboratorListRequest + { + Affiliation = CollaboratorAffiliation.Direct, + Permission = CollaboratorPermission.Triage + }; + + client.GetAll(1, request); + + connection.Received() + .GetAll( + Arg.Is(u => u.ToString() == "repositories/1/collaborators"), + Arg.Is>(d => d["affiliation"] == "direct" && d["permission"] == "triage"), + Args.ApiOptions); + + request = new RepositoryCollaboratorListRequest + { + Affiliation = CollaboratorAffiliation.Outside, + Permission = CollaboratorPermission.Push + }; + + client.GetAll(1, request); + + connection.Received() + .GetAll( + Arg.Is(u => u.ToString() == "repositories/1/collaborators"), + Arg.Is>(d => d["affiliation"] == "outside" && d["permission"] == "push"), + Args.ApiOptions); + } + [Fact] public async Task EnsuresNonNullArguments() { From 3b4332913bb3bfef41a4e0d95b373ef2ce15698a Mon Sep 17 00:00:00 2001 From: notauserx Date: Tue, 14 Feb 2023 12:17:42 +0600 Subject: [PATCH 38/39] add integration test for permission filter --- .../RepositoryCollaboratorClientTests.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs index b03603c82e..6ac5ce5959 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCollaboratorClientTests.cs @@ -26,6 +26,25 @@ public async Task ReturnsAllCollaborators() } } + [IntegrationTest] + public async Task ReturnsCollaboratorsWithPermissionFilter() + { + var github = Helper.GetAuthenticatedClient(); + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + + using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) + { + var fixture = github.Repository.Collaborator; + + var collaborators = await fixture.GetAll(context.RepositoryOwner, + context.RepositoryName, + new RepositoryCollaboratorListRequest() { Permission = CollaboratorPermission.Admin }); + + Assert.NotNull(collaborators); + Assert.Equal(1, collaborators.Count); + } + } + [IntegrationTest] public async Task ReturnsAllCollaboratorsWithRepositoryId() { From ec636f428c3d441f38be60592bffb349ca9d96f8 Mon Sep 17 00:00:00 2001 From: notauserx Date: Wed, 15 Feb 2023 10:09:48 +0600 Subject: [PATCH 39/39] add comment on Permission.cs file --- Octokit/Models/Common/Permission.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Octokit/Models/Common/Permission.cs b/Octokit/Models/Common/Permission.cs index 4b2ea2d17a..91a133ffeb 100644 --- a/Octokit/Models/Common/Permission.cs +++ b/Octokit/Models/Common/Permission.cs @@ -2,6 +2,9 @@ using System.Globalization; using Octokit.Internal; +// Permission.cs file houses all permission-related enums / classes +// This file was created based on this suggestion https://github.com/octokit/octokit.net/issues/2323#issuecomment-1322766701 + namespace Octokit { public enum InstallationReadWritePermissionLevel