diff --git a/AccessGridTest/ConsoleServiceTests.cs b/AccessGridTest/ConsoleServiceTests.cs index cd792e8..ece893e 100644 --- a/AccessGridTest/ConsoleServiceTests.cs +++ b/AccessGridTest/ConsoleServiceTests.cs @@ -1160,6 +1160,33 @@ public async Task CredentialProfilesListAsync_ShouldReturnProfiles() )), Times.Once); } + [Test] + public async Task CredentialProfilesListAsync_HandlesNullNumericFields() + { + // The API can return null for keys_diversified and file_size; the SDK + // previously typed these as non-nullable bool/int and crashed. + var json = """ + [ + { + "id": "cp_1", + "name": "Profile", + "keys": [ + { "ex_id": "key_1", "label": "Master Key", "keys_diversified": null, "source_key_index": null } + ], + "files": [ + { "ex_id": "file_1", "file_type": "Standard", "file_size": null } + ] + } + ] + """; + StubHttpResponse(json); + + var result = await _client.Console.CredentialProfiles.ListAsync(); + + Assert.That(result[0].Keys[0].KeysDiversified, Is.Null); + Assert.That(result[0].Files[0].FileSize, Is.Null); + } + [Test] public async Task CredentialProfilesListAsync_ShouldHandleEmptyList() { diff --git a/src/AccessGrid/Models.cs b/src/AccessGrid/Models.cs index acce0a3..757b858 100644 --- a/src/AccessGrid/Models.cs +++ b/src/AccessGrid/Models.cs @@ -1195,7 +1195,7 @@ public class CredentialProfileKey public string Label { get; set; } [JsonPropertyName("keys_diversified")] - public bool KeysDiversified { get; set; } + public bool? KeysDiversified { get; set; } [JsonPropertyName("source_key_index")] public int? SourceKeyIndex { get; set; } @@ -1213,7 +1213,7 @@ public class CredentialProfileFile public string FileType { get; set; } [JsonPropertyName("file_size")] - public int FileSize { get; set; } + public int? FileSize { get; set; } [JsonPropertyName("communication_settings")] public string CommunicationSettings { get; set; }