mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-05 23:06:10 +00:00
New integration tests for IAuthorizationsClient and IObservableAuthorizationsClient have been added.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration.Clients
|
||||
@@ -13,7 +12,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
var note = Helper.MakeNameWithTimestamp("Testing authentication");
|
||||
var newAuthorization = new NewAuthorization(
|
||||
note,
|
||||
new string[] { "user" });
|
||||
new[] { "user" });
|
||||
|
||||
var created = await github.Authorization.Create(newAuthorization);
|
||||
|
||||
@@ -27,6 +26,39 @@ namespace Octokit.Tests.Integration.Clients
|
||||
Assert.Equal(created.Note, get.Note);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetAuthorization()
|
||||
{
|
||||
var github = Helper.GetBasicAuthClient();
|
||||
|
||||
var authorizations = await github.Authorization.GetAll();
|
||||
Assert.NotEmpty(authorizations);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetAuthorizationWithApiOptions()
|
||||
{
|
||||
var github = Helper.GetBasicAuthClient();
|
||||
|
||||
var authorizations = await github.Authorization.GetAll(ApiOptions.None);
|
||||
Assert.NotEmpty(authorizations);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsNotEmptyAuthorizationsWithoutStart()
|
||||
{
|
||||
var github = Helper.GetBasicAuthClient();
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var authorizations = await github.Authorization.GetAll(options);
|
||||
Assert.NotEmpty(authorizations);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CannotCreatePersonalTokenWhenUsingOauthTokenCredentials()
|
||||
{
|
||||
@@ -34,7 +66,7 @@ namespace Octokit.Tests.Integration.Clients
|
||||
var note = Helper.MakeNameWithTimestamp("Testing authentication");
|
||||
var newAuthorization = new NewAuthorization(
|
||||
note,
|
||||
new string[] { "user" });
|
||||
new[] { "user" });
|
||||
|
||||
var error = Assert.ThrowsAsync<ForbiddenException>(() => github.Authorization.Create(newAuthorization));
|
||||
Assert.True(error.Result.Message.Contains("username and password Basic Auth"));
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
<Compile Include="Reactive\Enterprise\ObservableEnterpriseSearchIndexingClientTests.cs" />
|
||||
<Compile Include="Reactive\Enterprise\ObservableEnterpriseOrganizationClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableAssigneesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableAuthorizationsClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableIssuesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableMilestonesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableReleaseClientTests.cs" />
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Reactive;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration.Reactive
|
||||
{
|
||||
public class ObservableAuthorizationsClientTests
|
||||
{
|
||||
readonly ObservableAuthorizationsClient _authorizationsClient;
|
||||
|
||||
public ObservableAuthorizationsClientTests()
|
||||
{
|
||||
var github = Helper.GetBasicAuthClient();
|
||||
|
||||
_authorizationsClient = new ObservableAuthorizationsClient(github);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetAuthorization()
|
||||
{
|
||||
var authorization = await _authorizationsClient.GetAll();
|
||||
Assert.NotNull(authorization);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetAuthorizationWithApiOptions()
|
||||
{
|
||||
var authorization = await _authorizationsClient.GetAll(ApiOptions.None);
|
||||
Assert.NotNull(authorization);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsNotEmptyAuthorizationsWithoutStart()
|
||||
{
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 5,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var authorizations = await _authorizationsClient.GetAll(options).ToList();
|
||||
Assert.NotEmpty(authorizations);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user