Skip to content

Commit de044f1

Browse files
fiddlermikeym8rmclarenMichael Henderson
authored
GoDaddy AnyCA Plugin REST version 1.0.0 (#1) (#3)
1.0.0 - First production release of the GoDaddy AnyCA Gateway REST plugin Co-authored-by: Hayden <49427552+m8rmclaren@users.noreply.github.com> Co-authored-by: Michael Henderson <mhenderson@keyfactor.com>
1 parent 27d3f4c commit de044f1

28 files changed

Lines changed: 577 additions & 220 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,5 @@ healthchecksdb
348348
/cert.csr
349349

350350
*/C:
351+
352+
logs

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- 1.0.0
2+
- First production release of the GoDaddy AnyCA Gateway REST plugin that implements:
3+
- CA Sync
4+
- Download all issued certificates
5+
- Certificate enrollment for all published GoDaddy Certificate SKUs
6+
- Support certificate enrollment (new keys/certificate)
7+
- Support certificate renewal (extend the life of a previously issued certificate with the same or different domain names)
8+
- Support certificate re-issuance (new public/private keys with the same or different domain names)
9+
- Certificate revocation
10+
- Request revocation of a previously issued certificate

GoDaddy.Tests/FakeCaConfigProvider.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
using System.Security.Cryptography;
1616
using System.Security.Cryptography.X509Certificates;
1717
using Keyfactor.AnyGateway.Extensions;
18+
using Keyfactor.Extensions.CAPlugin.GoDaddy;
1819

19-
namespace GoDaddy.Tests;
20+
namespace Keyfactor.Extensions.CAPlugin.GoDaddyTests;
2021

2122
public class FakeCaConfigProvider : IAnyCAPluginConfigProvider
2223
{
@@ -36,7 +37,8 @@ Dictionary<string, object> IAnyCAPluginConfigProvider.CAConnectionData
3637
{ GoDaddyCAPluginConfig.ConfigConstants.ApiKey, Config.ApiKey },
3738
{ GoDaddyCAPluginConfig.ConfigConstants.ApiSecret, Config.ApiSecret },
3839
{ GoDaddyCAPluginConfig.ConfigConstants.BaseUrl, Config.BaseUrl },
39-
{ GoDaddyCAPluginConfig.ConfigConstants.ShopperId, Config.ShopperId }
40+
{ GoDaddyCAPluginConfig.ConfigConstants.ShopperId, Config.ShopperId },
41+
{ GoDaddyCAPluginConfig.ConfigConstants.Enabled , Config.Enabled },
4042
};
4143
}
4244
}

GoDaddy.Tests/FakeCertificateDataReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
using System.Security.Cryptography.X509Certificates;
1616
using Keyfactor.AnyGateway.Extensions;
1717

18-
namespace GoDaddy.Tests;
18+
namespace Keyfactor.Extensions.CAPlugin.GoDaddyTests;
1919

2020
public class FakeCertificateDataReader : ICertificateDataReader
2121
{

GoDaddy.Tests/FakeGoDaddyClient.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
using System.Collections.Concurrent;
1616
using System.Security.Cryptography;
1717
using System.Security.Cryptography.X509Certificates;
18-
using GoDaddy.Client;
18+
using Keyfactor.Extensions.CAPlugin.GoDaddy.Client;
1919
using Keyfactor.AnyGateway.Extensions;
2020
using Keyfactor.Logging;
2121
using Keyfactor.PKI.Enums.EJBCA;
2222
using Microsoft.Extensions.Logging;
2323

24-
namespace GoDaddy.Tests;
24+
namespace Keyfactor.Extensions.CAPlugin.GoDaddyTests;
2525

2626
public class FakeGoDaddyClient : IGoDaddyClient
2727
{
@@ -77,6 +77,25 @@ public FakeGoDaddyClient()
7777
public DateTime EnrollmentNotBefore;
7878
public DateTime EnrollmentNotAfter;
7979

80+
bool _fakeClientIsEnabled = true;
81+
82+
public Task Enable()
83+
{
84+
_fakeClientIsEnabled = true;
85+
return Task.CompletedTask;
86+
}
87+
88+
public Task Disable()
89+
{
90+
_fakeClientIsEnabled = false;
91+
return Task.CompletedTask;
92+
}
93+
94+
public bool IsEnabled()
95+
{
96+
return _fakeClientIsEnabled;
97+
}
98+
8099
public Task Ping()
81100
{
82101
return Task.CompletedTask;

GoDaddy.Tests/GoDaddyCAPlugin.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
using System.Collections.Concurrent;
1616
using System.Security.Cryptography;
1717
using System.Security.Cryptography.X509Certificates;
18-
using GoDaddy.Client;
1918
using Keyfactor.AnyGateway.Extensions;
19+
using Keyfactor.Extensions.CAPlugin.GoDaddy;
20+
using Keyfactor.Extensions.CAPlugin.GoDaddy.Client;
2021
using Keyfactor.Logging;
2122
using Keyfactor.PKI.Enums.EJBCA;
2223
using Microsoft.Extensions.Logging;
2324
using NLog.Extensions.Logging;
24-
using static GoDaddy.GoDaddyCAPluginConfig;
25+
using static Keyfactor.Extensions.CAPlugin.GoDaddy.GoDaddyCAPluginConfig;
2526

26-
namespace GoDaddy.Tests;
27+
namespace Keyfactor.Extensions.CAPlugin.GoDaddyTests;
2728

2829
public class GoDaddyCAPluginTests
2930
{
@@ -46,7 +47,8 @@ public void GoDaddyCAPlugin_Integration_SynchronizeCAFull_ReturnSuccess()
4647
ApiKey = env.ApiKey,
4748
ApiSecret = env.ApiSecret,
4849
BaseUrl = env.BaseApiUrl,
49-
ShopperId = env.ShopperId
50+
ShopperId = env.ShopperId,
51+
Enabled = true,
5052
};
5153

5254
IAnyCAPluginConfigProvider configProvider = new FakeCaConfigProvider(config);
@@ -514,12 +516,19 @@ public void GoDaddyCAPlugin_Integration_Enroll_ReturnSuccess()
514516
{
515517
// Arrange
516518
IntegrationTestingFact env = new();
519+
if (!env.BaseApiUrl.Contains("ote"))
520+
{
521+
_logger.LogWarning("Enrollment integration test should be run against the GoDaddy OT&E environment.");
522+
return;
523+
}
524+
517525
GoDaddyCAPluginConfig.Config config = new GoDaddyCAPluginConfig.Config()
518526
{
519527
ApiKey = env.ApiKey,
520528
ApiSecret = env.ApiSecret,
521529
BaseUrl = env.BaseApiUrl,
522-
ShopperId = env.ShopperId
530+
ShopperId = env.ShopperId,
531+
Enabled = true,
523532
};
524533

525534
IAnyCAPluginConfigProvider configProvider = new FakeCaConfigProvider(config);

GoDaddy.Tests/GoDaddyClient.cs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
// limitations under the License.
1414

1515
using System.Collections.Concurrent;
16-
using GoDaddy.Client;
16+
using Keyfactor.Extensions.CAPlugin.GoDaddy.Client;
1717
using Keyfactor.AnyGateway.Extensions;
1818
using Keyfactor.Logging;
1919
using Microsoft.Extensions.Logging;
2020
using NLog.Extensions.Logging;
2121

22-
namespace GoDaddy.Tests;
22+
namespace Keyfactor.Extensions.CAPlugin.GoDaddyTests;
2323

2424
public class ClientTests
2525
{
@@ -45,13 +45,44 @@ public void GoDaddyClient_Integration_DownloadAllIssuedCerts_ReturnSuccess()
4545
.WithShopperId(env.ShopperId)
4646
.Build();
4747

48+
client.Enable();
49+
4850
BlockingCollection<AnyCAPluginCertificate> certificates = new();
4951

5052
// Act
5153
int numberOfDownloadedCerts = client.DownloadAllIssuedCertificates(certificates, CancellationToken.None).Result;
5254
_logger.LogInformation($"Number of downloaded certificates: {numberOfDownloadedCerts}");
5355
}
5456

57+
[IntegrationTestingFact]
58+
public void GoDaddyClient_Integration_RateLimiter_ReturnSuccess()
59+
{
60+
// Arrange
61+
IntegrationTestingFact env = new();
62+
63+
IGoDaddyClient client = new GoDaddyClient.Builder()
64+
.WithBaseUrl(env.BaseApiUrl)
65+
.WithApiKey(env.ApiKey)
66+
.WithApiSecret(env.ApiSecret)
67+
.WithShopperId(env.ShopperId)
68+
.Build();
69+
70+
client.Enable();
71+
72+
// Act
73+
74+
List<Task> tasks = new();
75+
for (int i = 0; i < 100; i++)
76+
{
77+
_logger.LogDebug($"Request number: {i + 1}");
78+
tasks.Add(client.Ping());
79+
}
80+
foreach (var task in tasks)
81+
{
82+
task.Wait();
83+
}
84+
}
85+
5586
[IntegrationTestingFact]
5687
public void GoDaddyClient_Integration_GetCertificateDetails_ReturnSuccess()
5788
{
@@ -65,6 +96,8 @@ public void GoDaddyClient_Integration_GetCertificateDetails_ReturnSuccess()
6596
.WithShopperId(env.ShopperId)
6697
.Build();
6798

99+
client.Enable();
100+
68101
BlockingCollection<AnyCAPluginCertificate> certificates = new();
69102

70103
// Act

GoDaddy.Tests/GoDaddyEnrollment.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
using System.Collections.Concurrent;
1616
using System.Security.Cryptography;
1717
using System.Security.Cryptography.X509Certificates;
18-
using GoDaddy.Client;
18+
using Keyfactor.Extensions.CAPlugin.GoDaddy.Client;
1919
using Keyfactor.AnyGateway.Extensions;
2020
using Keyfactor.Logging;
2121
using Microsoft.Extensions.Logging;
2222
using Newtonsoft.Json;
2323
using NLog.Extensions.Logging;
24-
using static GoDaddy.GoDaddyCAPluginConfig;
24+
using static Keyfactor.Extensions.CAPlugin.GoDaddy.GoDaddyCAPluginConfig;
2525

26-
namespace GoDaddy.Tests;
26+
namespace Keyfactor.Extensions.CAPlugin.GoDaddyTests;
2727

2828
public class EnrollmentAbstractionTests
2929
{

GoDaddy.Tests/IntegrationTestingFact.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
namespace GoDaddy.Tests;
15+
namespace Keyfactor.Extensions.CAPlugin.GoDaddyTests;
1616

1717
public sealed class IntegrationTestingFact : FactAttribute
1818
{

GoDaddy.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.31903.59
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoDaddy.Tests", "GoDaddy.Tests\GoDaddy.Tests.csproj", "{9E0820D8-F573-4147-A958-58D65192A01B}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoDaddy", "GoDaddy\GoDaddy.csproj", "{65969507-D8EB-47B8-9DC4-78CD9B496423}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -18,5 +20,9 @@ Global
1820
{9E0820D8-F573-4147-A958-58D65192A01B}.Debug|Any CPU.Build.0 = Debug|Any CPU
1921
{9E0820D8-F573-4147-A958-58D65192A01B}.Release|Any CPU.ActiveCfg = Release|Any CPU
2022
{9E0820D8-F573-4147-A958-58D65192A01B}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{65969507-D8EB-47B8-9DC4-78CD9B496423}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{65969507-D8EB-47B8-9DC4-78CD9B496423}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{65969507-D8EB-47B8-9DC4-78CD9B496423}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{65969507-D8EB-47B8-9DC4-78CD9B496423}.Release|Any CPU.Build.0 = Release|Any CPU
2127
EndGlobalSection
2228
EndGlobal

0 commit comments

Comments
 (0)