Skip to content

Commit

Permalink
bug: Fixing issues with two factor authentication overload and certai…
Browse files Browse the repository at this point in the history
…n endpoints (#2524)
  • Loading branch information
JonruAlveus authored Aug 4, 2022
1 parent 6e72fda commit a7d5e33
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
8 changes: 4 additions & 4 deletions Octokit.Tests/Clients/RepositoriesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ public async Task RequestsTheCorrectUrlForOwnerAndRepoWithEmptyTopics()
await _client.ReplaceAllTopics("owner", "name", _emptyTopics);

_connection.Received()
.Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _emptyTopics, null);
.Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _emptyTopics);
}

[Fact]
Expand All @@ -1398,7 +1398,7 @@ public async Task RequestsTheCorrectUrlForOwnerAndRepoWithListOfTopics()
await _client.ReplaceAllTopics("owner", "name", _listOfTopics);

_connection.Received()
.Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _listOfTopics, null);
.Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/topics"), _listOfTopics);
}

[Fact]
Expand All @@ -1407,7 +1407,7 @@ public async Task RequestsTheCorrectUrlForRepoIdWithEmptyTopics()
await _client.ReplaceAllTopics(1234, _emptyTopics);

_connection.Received()
.Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _emptyTopics, null);
.Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _emptyTopics);
}

[Fact]
Expand All @@ -1416,7 +1416,7 @@ public async Task RequestsTheCorrectUrlForRepoIdWithListOfTopics()
await _client.ReplaceAllTopics(1234, _listOfTopics);

_connection.Received()
.Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _listOfTopics, null);
.Put<RepositoryTopics>(Arg.Is<Uri>(u => u.ToString() == "repositories/1234/topics"), _listOfTopics);
}
}
}
Expand Down
18 changes: 8 additions & 10 deletions Octokit.Tests/Clients/RepositoryBranchesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void RequestsTheCorrectUrl()
client.UpdateBranchProtection("owner", "repo", "branch", update);

connection.Received()
.Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), null);
.Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>());
}

[Fact]
Expand All @@ -222,7 +222,7 @@ public void RequestsTheCorrectUrlWithRepositoryId()
client.UpdateBranchProtection(1, "branch", update);

connection.Received()
.Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>(), null);
.Put<BranchProtectionSettings>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection"), Arg.Any<BranchProtectionSettingsUpdate>());
}

[Fact]
Expand Down Expand Up @@ -490,7 +490,7 @@ public void RequestsTheCorrectUrl()
client.UpdateRequiredStatusChecksContexts("owner", "repo", "branch", update);

connection.Received()
.Put<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), null);
.Put<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>());
}

[Fact]
Expand All @@ -503,7 +503,7 @@ public void RequestsTheCorrectUrlWithRepositoryId()
client.UpdateRequiredStatusChecksContexts(1, "branch", update);

connection.Received()
.Put<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>(), null);
.Put<IReadOnlyList<string>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/required_status_checks/contexts"), Arg.Any<IReadOnlyList<string>>());
}

[Fact]
Expand Down Expand Up @@ -1057,8 +1057,7 @@ public void RequestsTheCorrectUrl()
connection.Received()
.Put<IReadOnlyList<Team>>(
Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"),
Arg.Any<IReadOnlyList<string>>(),
null);
Arg.Any<IReadOnlyList<string>>());
}

[Fact]
Expand All @@ -1073,8 +1072,7 @@ public void RequestsTheCorrectUrlWithRepositoryId()
connection.Received()
.Put<IReadOnlyList<Team>>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"),
Arg.Any<IReadOnlyList<string>>(),
null);
Arg.Any<IReadOnlyList<string>>());
}

[Fact]
Expand Down Expand Up @@ -1264,7 +1262,7 @@ public void RequestsTheCorrectUrl()
client.UpdateProtectedBranchUserRestrictions("owner", "repo", "branch", newUsers);

connection.Received()
.Put<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), null);
.Put<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>());
}

[Fact]
Expand All @@ -1277,7 +1275,7 @@ public void RequestsTheCorrectUrlWithRepositoryId()
client.UpdateProtectedBranchUserRestrictions(1, "branch", newUsers);

connection.Received()
.Put<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>(), null);
.Put<IReadOnlyList<User>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/users"), Arg.Any<IReadOnlyList<string>>());
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions Octokit/Clients/RepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ public async Task<RepositoryTopics> ReplaceAllTopics(string owner, string name,
Ensure.ArgumentNotNull(topics, nameof(topics));

var endpoint = ApiUrls.RepositoryTopics(owner, name);
var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics, null).ConfigureAwait(false);
var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics).ConfigureAwait(false);

return data ?? new RepositoryTopics();
}
Expand All @@ -860,7 +860,7 @@ public async Task<RepositoryTopics> ReplaceAllTopics(long repositoryId, Reposito
Ensure.ArgumentNotNull(topics, nameof(topics));

var endpoint = ApiUrls.RepositoryTopics(repositoryId);
var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics, null).ConfigureAwait(false);
var data = await ApiConnection.Put<RepositoryTopics>(endpoint, topics).ConfigureAwait(false);

return data ?? new RepositoryTopics();
}
Expand Down
16 changes: 8 additions & 8 deletions Octokit/Clients/RepositoryBranchesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public Task<BranchProtectionSettings> UpdateBranchProtection(string owner, strin
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(update, nameof(update));

return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), update, null);
return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), update);
}

/// <summary>
Expand All @@ -193,7 +193,7 @@ public Task<BranchProtectionSettings> UpdateBranchProtection(long repositoryId,
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(update, nameof(update));

return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), update, null);
return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), update);
}

/// <summary>
Expand Down Expand Up @@ -431,7 +431,7 @@ public Task<IReadOnlyList<string>> UpdateRequiredStatusChecksContexts(string own
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(contexts, nameof(contexts));

return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, null);
return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts);
}

/// <summary>
Expand All @@ -449,7 +449,7 @@ public Task<IReadOnlyList<string>> UpdateRequiredStatusChecksContexts(long repos
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(contexts, nameof(contexts));

return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, null);
return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts);
}

/// <summary>
Expand Down Expand Up @@ -927,7 +927,7 @@ public Task<IReadOnlyList<Team>> UpdateProtectedBranchTeamRestrictions(string ow
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(teams, nameof(teams));

return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, null);
return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams);
}

/// <summary>
Expand All @@ -945,7 +945,7 @@ public Task<IReadOnlyList<Team>> UpdateProtectedBranchTeamRestrictions(long repo
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(teams, nameof(teams));

return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, null);
return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams);
}

/// <summary>
Expand Down Expand Up @@ -1079,7 +1079,7 @@ public Task<IReadOnlyList<User>> UpdateProtectedBranchUserRestrictions(string ow
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(users, nameof(users));

return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, null);
return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users);
}

/// <summary>
Expand All @@ -1097,7 +1097,7 @@ public Task<IReadOnlyList<User>> UpdateProtectedBranchUserRestrictions(long repo
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(users, nameof(users));

return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, null);
return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users);
}

/// <summary>
Expand Down

0 comments on commit a7d5e33

Please sign in to comment.