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

Rename client.User.Keys to client.User.GitSshKey #1354

Merged
merged 1 commit into from
Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions Octokit.Reactive/Clients/IObservableUsersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,17 @@ public interface IObservableUsersClient
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/keys/">Keys API documentation</a> for more information.
///</remarks>
[Obsolete("Ssh key information is now available under the GitSshKey property. This will be removed in a future update.")]
IObservableUserKeysClient Keys { get; }

/// <summary>
/// A client for GitHub's User Keys API
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/keys/">Keys API documentation</a> for more information.
///</remarks>
IObservableUserKeysClient GitSshKey { get; }

/// <summary>
/// A client for GitHub's UserUser GPG Keys API.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Octokit.Reactive/Clients/ObservableUserKeysClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public ObservableUserKeysClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");

_client = client.User.Keys;
_client = client.User.GitSshKey;
}

/// <summary>
Expand Down
12 changes: 12 additions & 0 deletions Octokit.Reactive/Clients/ObservableUsersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ public ObservableUsersClient(IGitHubClient client)

Followers = new ObservableFollowersClient(client);
Email = new ObservableUserEmailsClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
Keys = new ObservableUserKeysClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
GitSshKey = new ObservableUserKeysClient(client);
GpgKey = new ObservableUserGpgKeysClient(client);
Administration = new ObservableUserAdministrationClient(client);
}
Expand Down Expand Up @@ -77,8 +80,17 @@ public IObservable<User> Update(UserUpdate user)
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/keys/">Keys API documentation</a> for more information.
///</remarks>
[Obsolete("Ssh key information is now available under the GitSshKey property. This will be removed in a future update.")]
public IObservableUserKeysClient Keys { get; private set; }

/// <summary>
/// A client for GitHub's User Keys API
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/keys/">Keys API documentation</a> for more information.
///</remarks>
public IObservableUserKeysClient GitSshKey { get; private set; }

/// <summary>
/// A client for GitHub's UserUser GPG Keys API.
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions Octokit.Tests.Integration/Clients/UserKeysClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public async Task CanGetAllForCurrentUser()

using (var context = await github.CreatePublicKeyContext())
{
var keys = await github.User.Keys.GetAllForCurrent();
var keys = await github.User.GitSshKey.GetAllForCurrent();
Assert.NotEmpty(keys);

var first = keys[0];
Expand All @@ -30,7 +30,7 @@ public async Task CanGetAllForGivenUser()
{
var github = Helper.GetAuthenticatedClient();

var keys = await github.User.Keys.GetAll("shiftkey");
var keys = await github.User.GitSshKey.GetAll("shiftkey");
Assert.NotEmpty(keys);

var first = keys[0];
Expand All @@ -47,7 +47,7 @@ public async Task CanGetKeyById()

using (var context = await github.CreatePublicKeyContext())
{
var key = await github.User.Keys.Get(context.KeyId);
var key = await github.User.GitSshKey.Get(context.KeyId);

Assert.Equal(key.Title, context.KeyTitle);
Assert.Equal(key.Key, context.KeyData);
Expand All @@ -62,17 +62,17 @@ public async Task CanCreateAndDeleteKey()
string keyData = "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAjo4DqFKg8dOxiz/yjypmN1A4itU5QOStyYrfOFuTinesU/2zm9hqxJ5BctIhgtSHJ5foxkhsiBji0qrUg73Q25BThgNg8YFE8njr4EwjmqSqW13akx/zLV0GFFU0SdJ2F6rBldhi93lMnl0ex9swBqa3eLTY8C+HQGBI6MQUMw+BKp0oFkz87Kv+Pfp6lt/Uo32ejSxML1PT5hTH5n+fyl0ied+sRmPGZWmWoHB5Bc9mox7lB6I6A/ZgjtBqbEEn4HQ2/6vp4ojKfSgA4Mm7XMu0bZzX0itKjH1QWD9Lr5apV1cmZsj49Xf8SHucTtH+bq98hb8OOXEGFzplwsX2MQ==";
var github = Helper.GetAuthenticatedClient();

var key = await github.User.Keys.Create(new NewPublicKey(keyTitle, keyData));
var key = await github.User.GitSshKey.Create(new NewPublicKey(keyTitle, keyData));

Assert.NotNull(key);
Assert.Equal(key.Title, "title");
Assert.Equal(key.Key, keyData);

// Delete key
await github.User.Keys.Delete(key.Id);
await github.User.GitSshKey.Delete(key.Id);

// Verify key no longer exists
var keys = await github.User.Keys.GetAllForCurrent();
var keys = await github.User.GitSshKey.GetAllForCurrent();
Assert.False(keys.Any(k => k.Title == keyTitle && k.Key == keyData));
}
}
Expand Down
2 changes: 1 addition & 1 deletion Octokit.Tests.Integration/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static void DeleteKey(IConnection connection, int keyId)
try
{
var client = new GitHubClient(connection);
client.User.Keys.Delete(keyId).Wait(TimeSpan.FromSeconds(15));
client.User.GitSshKey.Delete(keyId).Wait(TimeSpan.FromSeconds(15));
}
catch { }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal static async Task<PublicKeyContext> CreatePublicKeyContext(this IGitHub
string keyTitle = "title";
string keyData = "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAjo4DqFKg8dOxiz/yjypmN1A4itU5QOStyYrfOFuTinesU/2zm9hqxJ5BctIhgtSHJ5foxkhsiBji0qrUg73Q25BThgNg8YFE8njr4EwjmqSqW13akx/zLV0GFFU0SdJ2F6rBldhi93lMnl0ex9swBqa3eLTY8C+HQGBI6MQUMw+BKp0oFkz87Kv+Pfp6lt/Uo32ejSxML1PT5hTH5n+fyl0ied+sRmPGZWmWoHB5Bc9mox7lB6I6A/ZgjtBqbEEn4HQ2/6vp4ojKfSgA4Mm7XMu0bZzX0itKjH1QWD9Lr5apV1cmZsj49Xf8SHucTtH+bq98hb8OOXEGFzplwsX2MQ==";

var key = await client.User.Keys.Create(new NewPublicKey(keyTitle, keyData));
var key = await client.User.GitSshKey.Create(new NewPublicKey(keyTitle, keyData));

return new PublicKeyContext(client.Connection, key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal static async Task<PublicKeyContext> CreatePublicKeyContext(this IObserv
string keyTitle = "title";
string keyData = "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAjo4DqFKg8dOxiz/yjypmN1A4itU5QOStyYrfOFuTinesU/2zm9hqxJ5BctIhgtSHJ5foxkhsiBji0qrUg73Q25BThgNg8YFE8njr4EwjmqSqW13akx/zLV0GFFU0SdJ2F6rBldhi93lMnl0ex9swBqa3eLTY8C+HQGBI6MQUMw+BKp0oFkz87Kv+Pfp6lt/Uo32ejSxML1PT5hTH5n+fyl0ied+sRmPGZWmWoHB5Bc9mox7lB6I6A/ZgjtBqbEEn4HQ2/6vp4ojKfSgA4Mm7XMu0bZzX0itKjH1QWD9Lr5apV1cmZsj49Xf8SHucTtH+bq98hb8OOXEGFzplwsX2MQ==";

var key = await client.User.Keys.Create(new NewPublicKey(keyTitle, keyData));
var key = await client.User.GitSshKey.Create(new NewPublicKey(keyTitle, keyData));

return new PublicKeyContext(client.Connection, key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task CanGetAllForCurrentUser()
{
using (var context = await _github.CreatePublicKeyContext())
{
var observable = _github.User.Keys.GetAllForCurrent();
var observable = _github.User.GitSshKey.GetAllForCurrent();
var keys = await observable.ToList();

Assert.NotEmpty(keys);
Expand All @@ -37,7 +37,7 @@ public async Task CanGetAllForCurrentUser()
[IntegrationTest]
public async Task CanGetAllForGivenUser()
{
var observable = _github.User.Keys.GetAll("shiftkey");
var observable = _github.User.GitSshKey.GetAll("shiftkey");
var keys = await observable.ToList();

Assert.NotEmpty(keys);
Expand All @@ -54,7 +54,7 @@ public async Task CanGetKeyById()
{
using (var context = await _github.CreatePublicKeyContext())
{
var observable = _github.User.Keys.Get(context.KeyId);
var observable = _github.User.GitSshKey.Get(context.KeyId);
var key = await observable;

Assert.Equal(key.Title, context.KeyTitle);
Expand All @@ -69,18 +69,18 @@ public async Task CanCreateAndDeleteKey()
string keyTitle = "title";
string keyData = "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAjo4DqFKg8dOxiz/yjypmN1A4itU5QOStyYrfOFuTinesU/2zm9hqxJ5BctIhgtSHJ5foxkhsiBji0qrUg73Q25BThgNg8YFE8njr4EwjmqSqW13akx/zLV0GFFU0SdJ2F6rBldhi93lMnl0ex9swBqa3eLTY8C+HQGBI6MQUMw+BKp0oFkz87Kv+Pfp6lt/Uo32ejSxML1PT5hTH5n+fyl0ied+sRmPGZWmWoHB5Bc9mox7lB6I6A/ZgjtBqbEEn4HQ2/6vp4ojKfSgA4Mm7XMu0bZzX0itKjH1QWD9Lr5apV1cmZsj49Xf8SHucTtH+bq98hb8OOXEGFzplwsX2MQ==";

var observable = _github.User.Keys.Create(new NewPublicKey(keyTitle, keyData));
var observable = _github.User.GitSshKey.Create(new NewPublicKey(keyTitle, keyData));
var key = await observable;

Assert.NotNull(key);
Assert.Equal(key.Title, "title");
Assert.Equal(key.Key, keyData);

// Delete key
await _github.User.Keys.Delete(key.Id);
await _github.User.GitSshKey.Delete(key.Id);

// Verify key no longer exists
var keys = await _github.User.Keys.GetAllForCurrent().ToList();
var keys = await _github.User.GitSshKey.GetAllForCurrent().ToList();
Assert.False(keys.Any(k => k.Title == keyTitle && k.Key == keyData));
}
}
Expand Down
10 changes: 5 additions & 5 deletions Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void CallsIntoClient()

client.GetAllForCurrent();

gitHubClient.User.Keys.Received().GetAllForCurrent(Arg.Any<ApiOptions>());
gitHubClient.User.GitSshKey.Received().GetAllForCurrent(Arg.Any<ApiOptions>());
}
}

Expand All @@ -31,7 +31,7 @@ public void CallsIntoClient()

client.GetAll("auser");

gitHubClient.User.Keys.Received().GetAll("auser", Arg.Any<ApiOptions>());
gitHubClient.User.GitSshKey.Received().GetAll("auser", Arg.Any<ApiOptions>());
}
}

Expand All @@ -45,7 +45,7 @@ public void CallsIntoClient()

client.Get(1);

gitHubClient.User.Keys.Received().Get(1);
gitHubClient.User.GitSshKey.Received().Get(1);
}
}

Expand All @@ -59,7 +59,7 @@ public void CallsIntoClient()

client.Create(new NewPublicKey("title", "ABCDEFG"));

gitHubClient.User.Keys.Received().Create(
gitHubClient.User.GitSshKey.Received().Create(
Arg.Is<NewPublicKey>(a =>
a.Title == "title" &&
a.Key == "ABCDEFG"));
Expand All @@ -76,7 +76,7 @@ public void CallsIntoClient()

client.Delete(1);

gitHubClient.User.Keys.Received().Delete(1);
gitHubClient.User.GitSshKey.Received().Delete(1);
}
}

Expand Down
12 changes: 11 additions & 1 deletion Octokit/Clients/IUsersClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;

namespace Octokit
Expand All @@ -25,8 +26,17 @@ public interface IUsersClient
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/keys/">Keys API documentation</a> for more information.
///</remarks>
[Obsolete("Ssh key information is now available under the GitSshKey property. This will be removed in a future update.")]
IUserKeysClient Keys { get; }

/// <summary>
/// A client for GitHub's User Keys API
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/keys/">Keys API documentation</a> for more information.
///</remarks>
IUserKeysClient GitSshKey { get; }

[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")]
IUserGpgKeysClient GpgKey { get; }

Expand Down
12 changes: 12 additions & 0 deletions Octokit/Clients/UsersClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public UsersClient(IApiConnection apiConnection) : base(apiConnection)
{
Email = new UserEmailsClient(apiConnection);
Followers = new FollowersClient(apiConnection);
#pragma warning disable CS0618 // Type or member is obsolete
Keys = new UserKeysClient(apiConnection);
#pragma warning restore CS0618 // Type or member is obsolete
GitSshKey = new UserKeysClient(apiConnection);
GpgKey = new UserGpgKeysClient(apiConnection);

Administration = new UserAdministrationClient(apiConnection);
Expand All @@ -41,8 +44,17 @@ public UsersClient(IApiConnection apiConnection) : base(apiConnection)
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/keys/">Keys API documentation</a> for more information.
///</remarks>
[Obsolete("Ssh key information is now available under the GitSshKey property. This will be removed in a future update.")]
public IUserKeysClient Keys { get; private set; }

/// <summary>
/// A client for GitHub's User Keys API
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/users/keys/">Keys API documentation</a> for more information.
///</remarks>
public IUserKeysClient GitSshKey { get; private set; }

/// <summary>
/// A client for GitHub's UserUser GPG Keys API.
/// </summary>
Expand Down