From 657e3429be655e146cd3b63cdde023d60ec06081 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sat, 27 Feb 2016 00:43:51 +1000 Subject: [PATCH] Revert "Implement extension methods and PublicKeyInfo class" This reverts commit 1d827350961b5d8e8f11603fbdc738720ccafa8f. --- .../Helpers/PublicKeyExtensionsTests.cs | 66 ------------------- Octokit.Tests/Octokit.Tests.csproj | 1 - Octokit/Helpers/ModelExtensions.cs | 6 +- Octokit/Helpers/PublicKeyExtensions.cs | 56 ---------------- Octokit/Helpers/PublicKeyInfo.cs | 22 ------- Octokit/Models/Response/PublicKey.cs | 5 -- Octokit/Models/Response/SshKeyInfo.cs | 2 +- Octokit/Octokit-Mono.csproj | 2 - Octokit/Octokit-MonoAndroid.csproj | 2 - Octokit/Octokit-Monotouch.csproj | 2 - Octokit/Octokit-Portable.csproj | 2 - Octokit/Octokit-netcore45.csproj | 2 - Octokit/Octokit.csproj | 2 - 13 files changed, 4 insertions(+), 166 deletions(-) delete mode 100644 Octokit.Tests/Helpers/PublicKeyExtensionsTests.cs delete mode 100644 Octokit/Helpers/PublicKeyExtensions.cs delete mode 100644 Octokit/Helpers/PublicKeyInfo.cs diff --git a/Octokit.Tests/Helpers/PublicKeyExtensionsTests.cs b/Octokit.Tests/Helpers/PublicKeyExtensionsTests.cs deleted file mode 100644 index 632e3cbd..00000000 --- a/Octokit.Tests/Helpers/PublicKeyExtensionsTests.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Xunit; -using Xunit.Extensions; - -namespace Octokit.Tests.Models -{ - public class PublicKeyExtensionsTests - { - public class TheGetKeyDataAndNameMethod - { - [Theory] - [InlineData("ssh-rsa AAAAB3NzaC1yc2EAAAABIwAA timothy.clem@gmail.com", "AAAAB3NzaC1yc2EAAAABIwAA", "timothy.clem@gmail.com")] - [InlineData("ssh-rsa AAAAB3NzaC1yc2EAAAABIwAA", "AAAAB3NzaC1yc2EAAAABIwAA", "")] - [InlineData("ssh-dss AAAAB3NzaC1yc2EAAAABIwAA", "AAAAB3NzaC1yc2EAAAABIwAA", "")] - [InlineData("ssh-dsa AAAAB3NzaC1yc2EAAAABIwAA", "AAAAB3NzaC1yc2EAAAABIwAA", "")] - public void CanParseKeyData(string raw, string data, string name) - { - var key = new PublicKey(raw); - - PublicKeyInfo keyInfo = key.GetKeyDataAndName(); - Assert.Equal(data, keyInfo.Data); - Assert.Equal(name, keyInfo.Name); - } - - [Theory] - [InlineData("")] - [InlineData(null)] - [InlineData("apsdfoihat")] - public void ParsingBadDataReturnsNull(string key) - { - Assert.Null(new PublicKey(key).GetKeyDataAndName()); - } - } - - public class TheHasSameDataAsMethod - { - [Fact] - public void ReturnsTrueWhenTwoKeysHaveTheSameData() - { - var key = new PublicKey("ssh-dsa AAAAB3NzaC1yc2EAAAABIwAA"); - var anotherKey = new PublicKey("ssh-rsa AAAAB3NzaC1yc2EAAAABIwAA"); - - Assert.True(key.HasSameDataAs(anotherKey)); - } - - [Fact] - public void ReturnsFalseWhenCompareKeyIsNull() - { - var key = new PublicKey("ssh-dsa AAAAB3NzaC1yc2EAAAABIwAA"); - - Assert.False(key.HasSameDataAs(null)); - } - - [Theory] - [InlineData(null, "ssh-dsa AAAAB3NzaC1yc2EAAAABIwAA")] - [InlineData("ssh-dsa AAAAB3NzaC1yc2EAAAABIwAA", null)] - [InlineData("ssh-dsa AAAAB3NzaC1yc2EAAAABIwAA", "ssh-dsa AAAAB3NzaC1yc2EAAAABIwAB")] - public void ReturnsFalseWhenTwoKeysHaveDifferentData(string firstKey, string secondKey) - { - var key = new PublicKey(firstKey); - var anotherKey = new PublicKey(secondKey); - - Assert.False(key.HasSameDataAs(anotherKey)); - } - } - } -} diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index a506a4fb..99537721 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -143,7 +143,6 @@ - diff --git a/Octokit/Helpers/ModelExtensions.cs b/Octokit/Helpers/ModelExtensions.cs index bbb0095b..6c347868 100644 --- a/Octokit/Helpers/ModelExtensions.cs +++ b/Octokit/Helpers/ModelExtensions.cs @@ -20,7 +20,7 @@ namespace Octokit /// Extract SSH key information from the API response /// /// Key details received from API - [Obsolete("This method is obsolete. Please use PublicKey.GetKeyDataAndName() instead.")] + [Obsolete("This method will be removed in a future release.")] public static SshKeyInfo GetKeyDataAndName(this SshKey sshKey) { Ensure.ArgumentNotNull(sshKey, "sshKey"); @@ -36,7 +36,7 @@ namespace Octokit /// /// Reference SSH key /// Key to compare - [Obsolete("This method is obsolete. Please use PublicKey.HasSameDataAs() instead.")] + [Obsolete("This method will be removed in a future release.")] public static bool HasSameDataAs(this SshKey key, SshKey otherKey) { Ensure.ArgumentNotNull(key, "key"); @@ -46,7 +46,7 @@ namespace Octokit return keyData != null && keyData == otherKey.GetKeyData(); } - [Obsolete("This method is obsolete. Please use PublicKey.GetKeyData() instead.")] + [Obsolete("This method will be removed in a future release.")] static string GetKeyData(this SshKey key) { var keyInfo = key.GetKeyDataAndName(); diff --git a/Octokit/Helpers/PublicKeyExtensions.cs b/Octokit/Helpers/PublicKeyExtensions.cs deleted file mode 100644 index 7e75cdb1..00000000 --- a/Octokit/Helpers/PublicKeyExtensions.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Text.RegularExpressions; - -namespace Octokit -{ - /// - /// Extensions for working with PublicKeys - /// - public static class PublicKeyExtensions - { -#if NETFX_CORE - static readonly Regex keyRegex = new Regex(@"ssh-[rd]s[as] (?\S+) ?(?.*)$"); -#else - static readonly Regex keyRegex = new Regex(@"ssh-[rd]s[as] (?\S+) ?(?.*)$", RegexOptions.Compiled); -#endif - - /// - /// Gets Name and Data components of a a - /// - /// received from API - /// object representing the data and name components of the - public static PublicKeyInfo GetKeyDataAndName(this PublicKey key) - { - Ensure.ArgumentNotNull(key, "sshKey"); - - var keyInfo = key.Key; - if (keyInfo == null) return null; - var match = keyRegex.Match(keyInfo); - return (match.Success ? new PublicKeyInfo(match.Groups["data"].Value, match.Groups["name"].Value) : null); - } - - /// - /// Gets data component from a - /// - /// received from API - static string GetKeyData(this PublicKey key) - { - var keyInfo = key.GetKeyDataAndName(); - return keyInfo == null ? null : keyInfo.Data; - } - - /// - /// Compare two s to see if they have equal data components - /// - /// Reference - /// to compare - public static bool HasSameDataAs(this PublicKey key, PublicKey otherKey) - { - Ensure.ArgumentNotNull(key, "key"); - - if (otherKey == null) return false; - var keyData = key.GetKeyData(); - return keyData != null && keyData == otherKey.GetKeyData(); - } - } -} diff --git a/Octokit/Helpers/PublicKeyInfo.cs b/Octokit/Helpers/PublicKeyInfo.cs deleted file mode 100644 index 60a127fe..00000000 --- a/Octokit/Helpers/PublicKeyInfo.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace Octokit -{ - /// - /// Represents the data and name parsed from a PublicKey. - /// - public class PublicKeyInfo - { - public PublicKeyInfo(string data, string name) - { - Ensure.ArgumentNotNull(data, "data"); - Ensure.ArgumentNotNull(name, "name"); - - Data = data; - Name = name; - } - - public string Data { get; private set; } - public string Name { get; private set; } - } -} \ No newline at end of file diff --git a/Octokit/Models/Response/PublicKey.cs b/Octokit/Models/Response/PublicKey.cs index 744d3750..1dac8f03 100644 --- a/Octokit/Models/Response/PublicKey.cs +++ b/Octokit/Models/Response/PublicKey.cs @@ -9,11 +9,6 @@ namespace Octokit { public PublicKey() { } - public PublicKey(string key) - { - Key = key; - } - public PublicKey(int id, string key, string url, string title) { Id = id; diff --git a/Octokit/Models/Response/SshKeyInfo.cs b/Octokit/Models/Response/SshKeyInfo.cs index 9790f1e9..a5da5401 100644 --- a/Octokit/Models/Response/SshKeyInfo.cs +++ b/Octokit/Models/Response/SshKeyInfo.cs @@ -5,7 +5,7 @@ namespace Octokit /// /// Represents the data and name parsed from the Ssh key. /// - [Obsolete("This helper class is obsolete. Please use PublicKeyInfo instead.")] + [Obsolete("This class will be removed in a future release.")] public class SshKeyInfo { public SshKeyInfo(string data, string name) diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index decd9e8e..eca26aea 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -456,8 +456,6 @@ - - \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index aba67e8e..5b72f2a8 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -465,8 +465,6 @@ - - \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index e8e0eca8..f02ec307 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -461,8 +461,6 @@ - - diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 456b5f08..e4d48b60 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -453,8 +453,6 @@ - - diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index a2c21ddf..da554e94 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -460,8 +460,6 @@ - - diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 9f58a48c..b30d6435 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -103,9 +103,7 @@ - -