Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Removing accept header previews #2515

Merged
merged 5 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Octokit.Tests.Integration/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public static void DeleteInvitations(IConnection connection, List<string> invite
{
foreach (var invitee in invitees)
{
connection.Delete(new Uri($"orgs/{Organization}/memberships/{invitee}", UriKind.Relative), null).Wait(TimeSpan.FromSeconds(15));
connection.Delete(new Uri($"orgs/{Organization}/memberships/{invitee}", UriKind.Relative)).Wait(TimeSpan.FromSeconds(15));
}
}
catch { }
Expand Down
4 changes: 0 additions & 4 deletions Octokit.Tests/Clients/AssigneesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public async Task RequestsCorrectUrl()
connection.Received().GetAll<User>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/assignees"),
null,
AcceptHeaders.StableVersion,
Args.ApiOptions);
}

Expand All @@ -40,7 +39,6 @@ public async Task RequestsCorrectUrlWithRepositoryId()
connection.Received().GetAll<User>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/assignees"),
null,
AcceptHeaders.StableVersion,
Args.ApiOptions);
}

Expand All @@ -62,7 +60,6 @@ public async Task RequestsCorrectUrlWithApiOptions()
connection.Received().GetAll<User>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/assignees"),
null,
AcceptHeaders.StableVersion,
options);
}

Expand All @@ -84,7 +81,6 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
connection.Received().GetAll<User>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/assignees"),
null,
AcceptHeaders.StableVersion,
options);
}

Expand Down
9 changes: 3 additions & 6 deletions Octokit.Tests/Clients/AuthorizationsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ public async Task ChecksApplicationAuthenticateAtCorrectUrl()

client.Received().Post<ApplicationAuthorization>(
Arg.Is<Uri>(u => u.ToString() == "applications/clientId/token"),
Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"),
"application/vnd.github.doctor-strange-preview+json");
Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"));
}

[Fact]
Expand Down Expand Up @@ -321,8 +320,7 @@ public async Task ResetsApplicationAuthenticationAtCorrectUrl()

client.Received().Patch<ApplicationAuthorization>(
Arg.Is<Uri>(u => u.ToString() == "applications/clientId/token"),
Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"),
"application/vnd.github.doctor-strange-preview+json");
Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"));
}

[Fact]
Expand Down Expand Up @@ -350,8 +348,7 @@ public async Task RevokesApplicationAuthenticationAtCorrectUrl()

client.Received().Delete(
Arg.Is<Uri>(u => u.ToString() == "applications/clientId/token"),
Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"),
"application/vnd.github.doctor-strange-preview+json");
Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"));
}

[Fact]
Expand Down
20 changes: 6 additions & 14 deletions Octokit.Tests/Clients/CheckSuitesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public async Task RequestsCorrectUrl()

connection.Received().Get<CheckSuite>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-suites/1"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.antiope-preview+json");
Arg.Any<Dictionary<string, string>>());
}

[Fact]
Expand All @@ -45,8 +44,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()

connection.Received().Get<CheckSuite>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-suites/1"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.antiope-preview+json");
Arg.Any<Dictionary<string, string>>());
}

[Fact]
Expand Down Expand Up @@ -220,8 +218,7 @@ public async Task RequestsCorrectUrl()

connection.Received().Patch<CheckSuitePreferencesResponse>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-suites/preferences"),
preferences,
"application/vnd.github.antiope-preview+json");
preferences);
}

[Fact]
Expand All @@ -236,8 +233,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()

connection.Received().Patch<CheckSuitePreferencesResponse>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-suites/preferences"),
preferences,
"application/vnd.github.antiope-preview+json");
preferences);
}

[Fact]
Expand Down Expand Up @@ -337,9 +333,7 @@ public async Task RequestsCorrectUrl()
await client.Rerequest("fake", "repo", 1);

connection.Connection.Received().Post(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-suites/1/rerequest"),
Args.Object,
"application/vnd.github.antiope-preview+json");
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/check-suites/1/rerequest"));
}

[Fact]
Expand All @@ -351,9 +345,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()
await client.Rerequest(1, 1);

connection.Connection.Received().Post(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-suites/1/rerequest"),
Args.Object,
"application/vnd.github.antiope-preview+json");
Arg.Is<Uri>(u => u.ToString() == "repositories/1/check-suites/1/rerequest"));
}

[Fact]
Expand Down
12 changes: 6 additions & 6 deletions Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task RequestsCorrectUrl()

await client.GetAll("fake", "repo", 42);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, Args.ApiOptions);
}

[Fact]
Expand All @@ -45,7 +45,7 @@ public async Task RequestsCorrectUrlApiOptions()

await client.GetAll("fake", "repo", 42, options);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, options);
}

[Fact]
Expand All @@ -56,7 +56,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()

await client.GetAll(1, 42);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42/reactions"), null, Args.ApiOptions);
}

[Fact]
Expand All @@ -74,7 +74,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdApiOptions()

await client.GetAll(1, 42, options);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42/reactions"), null, options);
}

[Fact]
Expand Down Expand Up @@ -113,7 +113,7 @@ public void RequestsCorrectUrl()

client.Create("fake", "repo", 1, newReaction);

connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json");
connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), newReaction);
}

[Fact]
Expand All @@ -126,7 +126,7 @@ public void RequestsCorrectUrlWithRepositoryId()

client.Create(1, 1, newReaction);

connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json");
connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/1/reactions"), newReaction);
}

[Fact]
Expand Down
16 changes: 4 additions & 12 deletions Octokit.Tests/Clients/DeploymentStatusClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public async Task RequestsCorrectUrl()
connection.Received().GetAll<
DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
null,
"application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json",
Args.ApiOptions);
}

Expand All @@ -36,7 +35,6 @@ public async Task RequestsCorrectUrlWithRepositoryId()

connection.Received().GetAll<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
null,
"application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json",
Args.ApiOptions);
}

Expand All @@ -59,7 +57,6 @@ public async Task RequestsCorrectUrlWithApiOptions()
connection.Received().GetAll<DeploymentStatus>(
Arg.Is<Uri>(u => u.ToString() == expectedUrl),
null,
"application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json",
options);
}

Expand All @@ -81,7 +78,6 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()

connection.Received().GetAll<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
null,
"application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json",
options);
}

Expand Down Expand Up @@ -137,8 +133,7 @@ public void PostsToCorrectUrl()
client.Create("owner", "repo", 1, newDeploymentStatus);

connection.Received().Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
newDeploymentStatus,
"application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json");
newDeploymentStatus);
}

[Fact]
Expand All @@ -151,8 +146,7 @@ public void PostsToCorrectUrlWithRepositoryId()
client.Create(1, 1, newDeploymentStatus);

connection.Received().Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Any<NewDeploymentStatus>(),
"application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json");
Arg.Any<NewDeploymentStatus>());
}

[Fact]
Expand Down Expand Up @@ -194,8 +188,7 @@ public void PassesNewDeploymentRequest()
client.Create("owner", "repo", 1, newDeploymentStatus);

connection.Received().Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
newDeploymentStatus,
Arg.Any<string>());
newDeploymentStatus);
}

[Fact]
Expand All @@ -208,8 +201,7 @@ public void SendsPreviewAcceptHeaders()
client.Create("owner", "repo", 1, newDeploymentStatus);

connection.Received(1).Post<DeploymentStatus>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Any<NewDeploymentStatus>(),
Arg.Is<string>(s => s == "application/vnd.github.ant-man-preview+json,application/vnd.github.flash-preview+json"));
Arg.Any<NewDeploymentStatus>());
}
}

Expand Down
12 changes: 3 additions & 9 deletions Octokit.Tests/Clients/DeploymentsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ public async Task RequestsCorrectUrl()
await client.GetAll(owner, name);

connection.Received(1)
.GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), null,
"application/vnd.github.ant-man-preview+json",
Args.ApiOptions);
.GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl), null, Args.ApiOptions);
}

[Fact]
Expand Down Expand Up @@ -97,7 +95,6 @@ public async Task RequestsCorrectUrlWithApiOptions()
connection.Received(1)
.GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
null,
"application/vnd.github.ant-man-preview+json",
options);
}

Expand Down Expand Up @@ -133,7 +130,6 @@ public void RequestsCorrectUrlWithPreviewAcceptHeaders()
connection.Received(1)
.GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Any<IDictionary<string, string>>(),
"application/vnd.github.ant-man-preview+json",
Args.ApiOptions);
}
}
Expand Down Expand Up @@ -185,8 +181,7 @@ public void PostsToDeploymentsUrl()
client.Create("owner", "name", newDeployment);

connection.Received(1).Post<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
newDeployment,
"application/vnd.github.ant-man-preview+json");
newDeployment);
}

[Fact]
Expand All @@ -211,8 +206,7 @@ public void SendsPreviewAcceptHeaders()
client.Create("owner", "name", newDeployment);

connection.Received(1).Post<Deployment>(Arg.Any<Uri>(),
Arg.Any<NewDeployment>(),
"application/vnd.github.ant-man-preview+json");
Arg.Any<NewDeployment>());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public async Task RequestsCorrectUrl()

connection.Received().GetAll<PreReceiveEnvironment>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments"),
null,
"application/vnd.github.eye-scream-preview+json",
Args.ApiOptions);
}

Expand All @@ -49,7 +48,6 @@ public async Task RequestsCorrectUrlWithApiOptions()

connection.Received().GetAll<PreReceiveEnvironment>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments"),
null,
"application/vnd.github.eye-scream-preview+json",
options);
}
}
Expand All @@ -65,8 +63,7 @@ public async Task RequestsTheCorrectUrl()
await client.Get(1);

connection.Received().Get<PreReceiveEnvironment>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments/1"),
null,
"application/vnd.github.eye-scream-preview+json");
null);
}
}

Expand All @@ -82,8 +79,7 @@ public async Task RequestsCorrectUrl()
await client.Create(data);

connection.Received().Post<PreReceiveEnvironment>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments"),
data,
"application/vnd.github.eye-scream-preview+json");
data);
}

[Fact]
Expand Down Expand Up @@ -115,8 +111,7 @@ public async Task RequestsTheCorrectUrl()
await client.Edit(1, data);

connection.Received().Patch<PreReceiveEnvironment>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments/1"),
data,
"application/vnd.github.eye-scream-preview+json");
data);
}

[Fact]
Expand All @@ -139,8 +134,7 @@ public async Task RequestsTheCorrectUrl()
await client.Delete(1);

connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments/1"),
Arg.Any<object>(),
"application/vnd.github.eye-scream-preview+json");
Arg.Any<object>());
}
}

Expand All @@ -155,8 +149,7 @@ public async Task RequestsTheCorrectUrl()
await client.DownloadStatus(1);

connection.Received().Get<PreReceiveEnvironmentDownload>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments/1/downloads/latest"),
null,
"application/vnd.github.eye-scream-preview+json");
null);
}
}

Expand All @@ -171,8 +164,7 @@ public async Task RequestsTheCorrectUrl()
await client.TriggerDownload(1);

connection.Received().Post<PreReceiveEnvironmentDownload>(Arg.Is<Uri>(u => u.ToString() == "admin/pre-receive-environments/1/downloads"),
Arg.Any<object>(),
"application/vnd.github.eye-scream-preview+json");
Arg.Any<object>());
}
}
}
Expand Down
Loading