Skip to content

Commit

Permalink
Merge pull request #59 from jasonmwebb-lv/master
Browse files Browse the repository at this point in the history
Added "enterprise" as possible list of values that can be deserialized
  • Loading branch information
zingz0r authored Jul 25, 2022
2 parents b5c23ed + cf141be commit b448bca
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
18 changes: 18 additions & 0 deletions CloudFlare.Client.Test/Accounts/AccountsUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ public async Task TestGetAccountDetailsAsync()
accountDetails.Result.Should().BeEquivalentTo(account);
}

[Fact]
public async Task TestGetAccountDetailsOnEnterpriseAsync()
{
var account = AccountTestData.Accounts.Last();

_wireMockServer
.Given(Request.Create().WithPath($"/{AccountEndpoints.Base}/{account.Id}").UsingGet())
.RespondWith(Response.Create().WithStatusCode(200)
.WithBody(WireMockResponseHelper.CreateTestResponse(account)));

using var client = new CloudFlareClient(WireMockConnection.ApiKeyAuthentication, _connectionInfo);

var accountDetails = await client.Accounts.GetDetailsAsync(account.Id);

accountDetails.Result.Should().BeEquivalentTo(account);
accountDetails.Result.Type.Should().Be(AccountType.Enterprise);
}

[Fact]
public async Task UpdateAccountAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class AccountTypeTest
[Fact]
public void TestSerialization()
{
JsonHelper.GetSerializedEnums<AccountType>().Should().BeEquivalentTo(new SortedSet<string> { "standard" });
JsonHelper.GetSerializedEnums<AccountType>().Should().BeEquivalentTo(new SortedSet<string> { "standard", "enterprise" });
}
}
}
}
17 changes: 17 additions & 0 deletions CloudFlare.Client.Test/TestData/AccountTestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ public static class AccountTestData
EnforceTwoFactorAuthentication = false,
AccessApprovalExpiry = null
}
},
new Account
{
CreatedOn = DateTime.UtcNow,
Id = "9018a5658j8e64153adb7aa01sd619fd",
Name = "Harry Potter",
Type = AccountType.Enterprise,
LegacyFlags =
new LegacyFlags
{
EnterpriseZoneQuota = new EnterpriseZoneQuota { Available = 0, Current = 0, Maximum = 0 }
},
Settings = new AdditionalAccountSettings
{
EnforceTwoFactorAuthentication = false,
AccessApprovalExpiry = null
}
}
};
}
Expand Down
8 changes: 7 additions & 1 deletion CloudFlare.Client/Enumerators/AccountType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public enum AccountType
/// Standard
/// </summary>
[EnumMember(Value = "standard")]
Standard
Standard,

/// <summary>
/// Enterprise
/// </summary>
[EnumMember(Value = "enterprise")]
Enterprise
}
}

0 comments on commit b448bca

Please sign in to comment.