Fixes as per PR review comments

This commit is contained in:
Henrik Andersson
2016-06-06 23:25:40 +10:00
parent df9ffd9b0d
commit 77b04efbdd
12 changed files with 38 additions and 39 deletions

View File

@@ -59,7 +59,7 @@ namespace Octokit.Reactive
/// See the <a href="https://developer.github.com/v3/users/gpg_keys/">User GPG Keys documentation</a> for more information. /// See the <a href="https://developer.github.com/v3/users/gpg_keys/">User GPG Keys documentation</a> for more information.
/// </remarks> /// </remarks>
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
IObservableUserGpgKeysClient GpgKeys { get; } IObservableUserGpgKeysClient GpgKey { get; }
/// <summary> /// <summary>
/// A client for GitHub's User Administration API /// A client for GitHub's User Administration API

View File

@@ -27,7 +27,7 @@ namespace Octokit.Reactive
{ {
Ensure.ArgumentNotNull(client, "client"); Ensure.ArgumentNotNull(client, "client");
_client = client.User.GpgKeys; _client = client.User.GpgKey;
} }
/// <summary> /// <summary>

View File

@@ -17,7 +17,7 @@ namespace Octokit.Reactive
Followers = new ObservableFollowersClient(client); Followers = new ObservableFollowersClient(client);
Email = new ObservableUserEmailsClient(client); Email = new ObservableUserEmailsClient(client);
Keys = new ObservableUserKeysClient(client); Keys = new ObservableUserKeysClient(client);
GpgKeys = new ObservableUserGpgKeysClient(client); GpgKey = new ObservableUserGpgKeysClient(client);
Administration = new ObservableUserAdministrationClient(client); Administration = new ObservableUserAdministrationClient(client);
} }
@@ -85,8 +85,7 @@ namespace Octokit.Reactive
/// <remarks> /// <remarks>
/// See the <a href="https://developer.github.com/v3/users/gpg_keys/">User GPG Keys documentation</a> for more information. /// See the <a href="https://developer.github.com/v3/users/gpg_keys/">User GPG Keys documentation</a> for more information.
/// </remarks> /// </remarks>
public IObservableUserGpgKeysClient GpgKeys { get; private set; } public IObservableUserGpgKeysClient GpgKey { get; private set; }
/// <summary> /// <summary>
/// A client for GitHub's User Administration API /// A client for GitHub's User Administration API

View File

@@ -40,7 +40,7 @@ VO/+BCBsaoT4g1FFOmJhbBAD3G72yslBnUJmqKP/39pi
using (var context = await github.CreateGpgKeyContext()) using (var context = await github.CreateGpgKeyContext())
{ {
var keys = await github.User.GpgKeys.GetAllForCurrent(); var keys = await github.User.GpgKey.GetAllForCurrent();
Assert.NotEmpty(keys); Assert.NotEmpty(keys);
var first = keys[0]; var first = keys[0];
@@ -58,7 +58,7 @@ VO/+BCBsaoT4g1FFOmJhbBAD3G72yslBnUJmqKP/39pi
var github = Helper.GetBasicAuthClient(); var github = Helper.GetBasicAuthClient();
using (var context = await github.CreateGpgKeyContext()) using (var context = await github.CreateGpgKeyContext())
{ {
var key = await github.User.GpgKeys.Get(context.GpgKeyId); var key = await github.User.GpgKey.Get(context.GpgKeyId);
Assert.Equal(context.GpgKeyId, key.Id); Assert.Equal(context.GpgKeyId, key.Id);
Assert.Equal(context.KeyId, key.KeyId); Assert.Equal(context.KeyId, key.KeyId);
@@ -71,16 +71,16 @@ VO/+BCBsaoT4g1FFOmJhbBAD3G72yslBnUJmqKP/39pi
{ {
var github = Helper.GetBasicAuthClient(); var github = Helper.GetBasicAuthClient();
var key = await github.User.GpgKeys.Create(new NewGpgKey(publicKey)); var key = await github.User.GpgKey.Create(new NewGpgKey(publicKey));
Assert.NotNull(key); Assert.NotNull(key);
Assert.Equal(knownPublicKey, key.PublicKey); Assert.Equal(knownPublicKey, key.PublicKey);
Assert.Equal(knownKeyId, key.KeyId); Assert.Equal(knownKeyId, key.KeyId);
// Delete the key // Delete the key
await github.User.GpgKeys.Delete(key.Id); await github.User.GpgKey.Delete(key.Id);
// Verify key no longer exists // Verify key no longer exists
var keys = await github.User.GpgKeys.GetAllForCurrent(); var keys = await github.User.GpgKey.GetAllForCurrent();
Assert.False(keys.Any(k => k.KeyId == knownKeyId && k.PublicKey == knownPublicKey)); Assert.False(keys.Any(k => k.KeyId == knownKeyId && k.PublicKey == knownPublicKey));
} }
@@ -89,13 +89,13 @@ VO/+BCBsaoT4g1FFOmJhbBAD3G72yslBnUJmqKP/39pi
{ {
var github = Helper.GetBasicAuthClient(); var github = Helper.GetBasicAuthClient();
var key = await github.User.GpgKeys.Create(new NewGpgKey(publicKey)); var key = await github.User.GpgKey.Create(new NewGpgKey(publicKey));
Assert.NotNull(key); Assert.NotNull(key);
Assert.ThrowsAsync<ApiValidationException>(async () => await github.User.GpgKeys.Create(new NewGpgKey(publicKey))); Assert.ThrowsAsync<ApiValidationException>(async () => await github.User.GpgKey.Create(new NewGpgKey(publicKey)));
await github.User.GpgKeys.Delete(key.Id); await github.User.GpgKey.Delete(key.Id);
var keys = await github.User.GpgKeys.GetAllForCurrent(); var keys = await github.User.GpgKey.GetAllForCurrent();
Assert.False(keys.Any(k => k.KeyId == knownKeyId && k.PublicKey == knownPublicKey)); Assert.False(keys.Any(k => k.KeyId == knownKeyId && k.PublicKey == knownPublicKey));
} }
} }

View File

@@ -74,7 +74,7 @@ VO/+BCBsaoT4g1FFOmJhbBAD3G72yslBnUJmqKP/39pi
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----
"; ";
var key = await client.User.GpgKeys.Create(new NewGpgKey(publicKey)); var key = await client.User.GpgKey.Create(new NewGpgKey(publicKey));
return new GpgKeyContext(key); return new GpgKeyContext(key);
} }

View File

@@ -30,7 +30,7 @@ namespace Octokit.Tests.Integration.Helpers
var api = Helper.GetBasicAuthClient(); var api = Helper.GetBasicAuthClient();
try try
{ {
api.User.GpgKeys.Delete(Key.Id).Wait(TimeSpan.FromSeconds(15)); api.User.GpgKey.Delete(Key.Id).Wait(TimeSpan.FromSeconds(15));
} }
catch { } catch { }
} }

View File

@@ -76,7 +76,7 @@ VO/+BCBsaoT4g1FFOmJhbBAD3G72yslBnUJmqKP/39pi
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----
"; ";
var key = await client.User.GpgKeys.Create(new NewGpgKey(publicKey)); var key = await client.User.GpgKey.Create(new NewGpgKey(publicKey));
return new GpgKeyContext(key); return new GpgKeyContext(key);
} }

View File

@@ -27,7 +27,7 @@ namespace Octokit.Tests.Integration.Reactive
{ {
using (var context = _gitHubClient.CreateGpgKeyContext()) using (var context = _gitHubClient.CreateGpgKeyContext())
{ {
var observable = _gitHubClient.User.GpgKeys.GetAllForCurrent(); var observable = _gitHubClient.User.GpgKey.GetAllForCurrent();
var keys = await observable.ToList(); var keys = await observable.ToList();
Assert.NotEmpty(keys); Assert.NotEmpty(keys);
@@ -46,7 +46,7 @@ namespace Octokit.Tests.Integration.Reactive
{ {
using (var context = await _gitHubClient.CreateGpgKeyContext()) using (var context = await _gitHubClient.CreateGpgKeyContext())
{ {
var observable = _gitHubClient.User.GpgKeys.Get(context.GpgKeyId); var observable = _gitHubClient.User.GpgKey.Get(context.GpgKeyId);
var key = await observable; var key = await observable;
Assert.Equal(knownKeyId, key.KeyId); Assert.Equal(knownKeyId, key.KeyId);
@@ -77,7 +77,7 @@ VO/+BCBsaoT4g1FFOmJhbBAD3G72yslBnUJmqKP/39pi
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----
"; ";
// Create a key // Create a key
var observable = _gitHubClient.User.GpgKeys.Create(new NewGpgKey(publicKey)); var observable = _gitHubClient.User.GpgKey.Create(new NewGpgKey(publicKey));
var key = await observable; var key = await observable;
Assert.NotNull(key); Assert.NotNull(key);
@@ -85,10 +85,10 @@ VO/+BCBsaoT4g1FFOmJhbBAD3G72yslBnUJmqKP/39pi
Assert.Equal(knownPublicKey, key.PublicKey); Assert.Equal(knownPublicKey, key.PublicKey);
// Delete the key // Delete the key
await _gitHubClient.User.GpgKeys.Delete(key.Id); await _gitHubClient.User.GpgKey.Delete(key.Id);
// Verify key no longer exists // Verify key no longer exists
var keys = await _gitHubClient.User.GpgKeys.GetAllForCurrent().ToList(); var keys = await _gitHubClient.User.GpgKey.GetAllForCurrent().ToList();
Assert.False(keys.Any(k => k.KeyId == knownKeyId && k.PublicKey == knownPublicKey)); Assert.False(keys.Any(k => k.KeyId == knownKeyId && k.PublicKey == knownPublicKey));
} }
} }

View File

@@ -28,13 +28,13 @@ namespace Octokit.Tests.Clients
var connection = Substitute.For<IApiConnection>(); var connection = Substitute.For<IApiConnection>();
var client = new UserGpgKeysClient(connection); var client = new UserGpgKeysClient(connection);
var expectedUri = ApiUrls.GpgKeys().ToString(); var expectedUri = "user/gpg_keys";
client.GetAllForCurrent(); client.GetAllForCurrent();
connection.Received().GetAll<GpgKey>( connection.Received().GetAll<GpgKey>(
Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Is<Uri>(u => u.ToString() == expectedUri),
Arg.Any<Dictionary<string, string>>(), Arg.Any<Dictionary<string, string>>(),
Arg.Is<string>(s => s == AcceptHeaders.GpgKeysPreview), Arg.Is<string>(s => s == "application/vnd.github.cryptographer-preview+sha"),
Arg.Any<ApiOptions>()); Arg.Any<ApiOptions>());
} }
} }
@@ -47,13 +47,13 @@ namespace Octokit.Tests.Clients
var connection = Substitute.For<IApiConnection>(); var connection = Substitute.For<IApiConnection>();
var client = new UserGpgKeysClient(connection); var client = new UserGpgKeysClient(connection);
var expectedUri = ApiUrls.GpgKeys(1).ToString(); var expectedUri = "user/gpg_keys/1";
client.Get(1); client.Get(1);
connection.Received().Get<GpgKey>( connection.Received().Get<GpgKey>(
Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Is<Uri>(u => u.ToString() == expectedUri),
Arg.Any<Dictionary<string, string>>(), Arg.Any<Dictionary<string, string>>(),
Arg.Is<string>(s => s == AcceptHeaders.GpgKeysPreview)); Arg.Is<string>(s => s == "application/vnd.github.cryptographer-preview+sha"));
} }
} }
@@ -72,13 +72,13 @@ namespace Octokit.Tests.Clients
var connection = Substitute.For<IApiConnection>(); var connection = Substitute.For<IApiConnection>();
var client = new UserGpgKeysClient(connection); var client = new UserGpgKeysClient(connection);
var expectedUri = ApiUrls.GpgKeys().ToString(); var expectedUri = "user/gpg_keys";
client.Create(new NewGpgKey("ABCDEFG")); client.Create(new NewGpgKey("ABCDEFG"));
connection.Received().Post<GpgKey>( connection.Received().Post<GpgKey>(
Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Is<Uri>(u => u.ToString() == expectedUri),
Arg.Any<object>(), Arg.Any<object>(),
Arg.Is<string>(s => s == AcceptHeaders.GpgKeysPreview)); Arg.Is<string>(s => s == "application/vnd.github.cryptographer-preview+sha"));
} }
[Fact] [Fact]
@@ -87,11 +87,11 @@ namespace Octokit.Tests.Clients
var connection = Substitute.For<IApiConnection>(); var connection = Substitute.For<IApiConnection>();
var client = new UserGpgKeysClient(connection); var client = new UserGpgKeysClient(connection);
var expectedUri = ApiUrls.GpgKeys().ToString(); var expectedUri = "user/gpg_keys";
client.Create(new NewGpgKey("ABCDEFG")); client.Create(new NewGpgKey("ABCDEFG"));
connection.Received().Post<GpgKey>( connection.Received().Post<GpgKey>(
Arg.Any<Uri>(), Arg.Is<Uri>(u => u.ToString() == expectedUri),
Arg.Is<NewGpgKey>(a => Arg.Is<NewGpgKey>(a =>
a.ArmoredPublicKey == "ABCDEFG"), a.ArmoredPublicKey == "ABCDEFG"),
Arg.Any<string>()); Arg.Any<string>());
@@ -106,13 +106,13 @@ namespace Octokit.Tests.Clients
var connection = Substitute.For<IApiConnection>(); var connection = Substitute.For<IApiConnection>();
var client = new UserGpgKeysClient(connection); var client = new UserGpgKeysClient(connection);
var expectedUri = ApiUrls.GpgKeys(1).ToString(); var expectedUri = "user/gpg_keys/1";
client.Delete(1); client.Delete(1);
connection.Received().Delete( connection.Received().Delete(
Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Is<Uri>(u => u.ToString() == expectedUri),
Arg.Any<object>(), Arg.Any<object>(),
Arg.Is<string>(s => s == AcceptHeaders.GpgKeysPreview)); Arg.Is<string>(s => s == "application/vnd.github.cryptographer-preview+sha"));
} }
} }
} }

View File

@@ -21,7 +21,7 @@ namespace Octokit.Tests.Reactive
client.GetAllForCurrent(); client.GetAllForCurrent();
githubClient.User.GpgKeys.Received().GetAllForCurrent(Arg.Any<ApiOptions>()); githubClient.User.GpgKey.Received().GetAllForCurrent(Arg.Any<ApiOptions>());
} }
} }
@@ -35,7 +35,7 @@ namespace Octokit.Tests.Reactive
client.Get(1); client.Get(1);
githubClient.User.GpgKeys.Received().Get(1); githubClient.User.GpgKey.Received().Get(1);
} }
} }
@@ -49,7 +49,7 @@ namespace Octokit.Tests.Reactive
client.Create(new NewGpgKey("ABCDEFG")); client.Create(new NewGpgKey("ABCDEFG"));
githubClient.User.GpgKeys.Received().Create(Arg.Is<NewGpgKey>(k => k.ArmoredPublicKey == "ABCDEFG")); githubClient.User.GpgKey.Received().Create(Arg.Is<NewGpgKey>(k => k.ArmoredPublicKey == "ABCDEFG"));
} }
} }
@@ -63,7 +63,7 @@ namespace Octokit.Tests.Reactive
client.Delete(1); client.Delete(1);
githubClient.User.GpgKeys.Received().Delete(1); githubClient.User.GpgKey.Received().Delete(1);
} }
} }

View File

@@ -28,7 +28,7 @@ namespace Octokit
IUserKeysClient Keys { get; } IUserKeysClient Keys { get; }
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
IUserGpgKeysClient GpgKeys { get; } IUserGpgKeysClient GpgKey { get; }
/// <summary> /// <summary>
/// Returns the user specified by the login. /// Returns the user specified by the login.

View File

@@ -22,7 +22,7 @@ namespace Octokit
Email = new UserEmailsClient(apiConnection); Email = new UserEmailsClient(apiConnection);
Followers = new FollowersClient(apiConnection); Followers = new FollowersClient(apiConnection);
Keys = new UserKeysClient(apiConnection); Keys = new UserKeysClient(apiConnection);
GpgKeys = new UserGpgKeysClient(apiConnection); GpgKey = new UserGpgKeysClient(apiConnection);
Administration = new UserAdministrationClient(apiConnection); Administration = new UserAdministrationClient(apiConnection);
} }
@@ -49,7 +49,7 @@ namespace Octokit
/// <remarks> /// <remarks>
/// See the <a href="https://developer.github.com/v3/users/gpg_keys/">User GPG Keys documentation</a> for more information. /// See the <a href="https://developer.github.com/v3/users/gpg_keys/">User GPG Keys documentation</a> for more information.
/// </remarks> /// </remarks>
public IUserGpgKeysClient GpgKeys { get; private set; } public IUserGpgKeysClient GpgKey { get; private set; }
/// <summary> /// <summary>
/// Returns the user specified by the login. /// Returns the user specified by the login.