From a7d5e339d5aad1b83856ccd3f3a2fa4467b351aa Mon Sep 17 00:00:00 2001 From: Chris Simpson Date: Thu, 4 Aug 2022 21:39:47 +0100 Subject: [PATCH] bug: Fixing issues with two factor authentication overload and certain endpoints (#2524) --- .../Clients/RepositoriesClientTests.cs | 8 ++++---- .../Clients/RepositoryBranchesClientTests.cs | 18 ++++++++---------- Octokit/Clients/RepositoriesClient.cs | 4 ++-- Octokit/Clients/RepositoryBranchesClient.cs | 16 ++++++++-------- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index c7496d35b8..9ed62ed435 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -1389,7 +1389,7 @@ public async Task RequestsTheCorrectUrlForOwnerAndRepoWithEmptyTopics() await _client.ReplaceAllTopics("owner", "name", _emptyTopics); _connection.Received() - .Put(Arg.Is(u => u.ToString() == "repos/owner/name/topics"), _emptyTopics, null); + .Put(Arg.Is(u => u.ToString() == "repos/owner/name/topics"), _emptyTopics); } [Fact] @@ -1398,7 +1398,7 @@ public async Task RequestsTheCorrectUrlForOwnerAndRepoWithListOfTopics() await _client.ReplaceAllTopics("owner", "name", _listOfTopics); _connection.Received() - .Put(Arg.Is(u => u.ToString() == "repos/owner/name/topics"), _listOfTopics, null); + .Put(Arg.Is(u => u.ToString() == "repos/owner/name/topics"), _listOfTopics); } [Fact] @@ -1407,7 +1407,7 @@ public async Task RequestsTheCorrectUrlForRepoIdWithEmptyTopics() await _client.ReplaceAllTopics(1234, _emptyTopics); _connection.Received() - .Put(Arg.Is(u => u.ToString() == "repositories/1234/topics"), _emptyTopics, null); + .Put(Arg.Is(u => u.ToString() == "repositories/1234/topics"), _emptyTopics); } [Fact] @@ -1416,7 +1416,7 @@ public async Task RequestsTheCorrectUrlForRepoIdWithListOfTopics() await _client.ReplaceAllTopics(1234, _listOfTopics); _connection.Received() - .Put(Arg.Is(u => u.ToString() == "repositories/1234/topics"), _listOfTopics, null); + .Put(Arg.Is(u => u.ToString() == "repositories/1234/topics"), _listOfTopics); } } } diff --git a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs index de8f42424e..6d5160ec55 100644 --- a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs @@ -208,7 +208,7 @@ public void RequestsTheCorrectUrl() client.UpdateBranchProtection("owner", "repo", "branch", update); connection.Received() - .Put(Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), Arg.Any(), null); + .Put(Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), Arg.Any()); } [Fact] @@ -222,7 +222,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() client.UpdateBranchProtection(1, "branch", update); connection.Received() - .Put(Arg.Is(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any(), null); + .Put(Arg.Is(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any()); } [Fact] @@ -490,7 +490,7 @@ public void RequestsTheCorrectUrl() client.UpdateRequiredStatusChecksContexts("owner", "repo", "branch", update); connection.Received() - .Put>(Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any>(), null); + .Put>(Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any>()); } [Fact] @@ -503,7 +503,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() client.UpdateRequiredStatusChecksContexts(1, "branch", update); connection.Received() - .Put>(Arg.Is(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any>(), null); + .Put>(Arg.Is(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any>()); } [Fact] @@ -1057,8 +1057,7 @@ public void RequestsTheCorrectUrl() connection.Received() .Put>( Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"), - Arg.Any>(), - null); + Arg.Any>()); } [Fact] @@ -1073,8 +1072,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() connection.Received() .Put>( Arg.Is(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"), - Arg.Any>(), - null); + Arg.Any>()); } [Fact] @@ -1264,7 +1262,7 @@ public void RequestsTheCorrectUrl() client.UpdateProtectedBranchUserRestrictions("owner", "repo", "branch", newUsers); connection.Received() - .Put>(Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any>(), null); + .Put>(Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any>()); } [Fact] @@ -1277,7 +1275,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() client.UpdateProtectedBranchUserRestrictions(1, "branch", newUsers); connection.Received() - .Put>(Arg.Is(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any>(), null); + .Put>(Arg.Is(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any>()); } [Fact] diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index bd1f5d6ee8..803361991f 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -838,7 +838,7 @@ public async Task ReplaceAllTopics(string owner, string name, Ensure.ArgumentNotNull(topics, nameof(topics)); var endpoint = ApiUrls.RepositoryTopics(owner, name); - var data = await ApiConnection.Put(endpoint, topics, null).ConfigureAwait(false); + var data = await ApiConnection.Put(endpoint, topics).ConfigureAwait(false); return data ?? new RepositoryTopics(); } @@ -860,7 +860,7 @@ public async Task ReplaceAllTopics(long repositoryId, Reposito Ensure.ArgumentNotNull(topics, nameof(topics)); var endpoint = ApiUrls.RepositoryTopics(repositoryId); - var data = await ApiConnection.Put(endpoint, topics, null).ConfigureAwait(false); + var data = await ApiConnection.Put(endpoint, topics).ConfigureAwait(false); return data ?? new RepositoryTopics(); } diff --git a/Octokit/Clients/RepositoryBranchesClient.cs b/Octokit/Clients/RepositoryBranchesClient.cs index 852bc5bb34..8126fc0ea6 100644 --- a/Octokit/Clients/RepositoryBranchesClient.cs +++ b/Octokit/Clients/RepositoryBranchesClient.cs @@ -175,7 +175,7 @@ public Task UpdateBranchProtection(string owner, strin Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Put(ApiUrls.RepoBranchProtection(owner, name, branch), update, null); + return ApiConnection.Put(ApiUrls.RepoBranchProtection(owner, name, branch), update); } /// @@ -193,7 +193,7 @@ public Task UpdateBranchProtection(long repositoryId, Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Put(ApiUrls.RepoBranchProtection(repositoryId, branch), update, null); + return ApiConnection.Put(ApiUrls.RepoBranchProtection(repositoryId, branch), update); } /// @@ -431,7 +431,7 @@ public Task> UpdateRequiredStatusChecksContexts(string own Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Put>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, null); + return ApiConnection.Put>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts); } /// @@ -449,7 +449,7 @@ public Task> UpdateRequiredStatusChecksContexts(long repos Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Put>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, null); + return ApiConnection.Put>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts); } /// @@ -927,7 +927,7 @@ public Task> UpdateProtectedBranchTeamRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Put>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, null); + return ApiConnection.Put>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams); } /// @@ -945,7 +945,7 @@ public Task> UpdateProtectedBranchTeamRestrictions(long repo Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Put>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, null); + return ApiConnection.Put>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams); } /// @@ -1079,7 +1079,7 @@ public Task> UpdateProtectedBranchUserRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Put>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, null); + return ApiConnection.Put>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users); } /// @@ -1097,7 +1097,7 @@ public Task> UpdateProtectedBranchUserRestrictions(long repo Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Put>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, null); + return ApiConnection.Put>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users); } ///