Add batch DNS operations documentation and refine logging format in CfDnsClient. Extend tests for record creation and deletion.

This commit is contained in:
2025-12-27 16:48:26 +01:00
parent a3dc89e2c5
commit a965f21d6b
3 changed files with 133 additions and 2 deletions
@@ -272,7 +272,7 @@ public class CfDnsClient extends CfBasicHttpClient {
if (changed) {
log.debug("Record {} of the type [{}] successful deleted.", rec.getName(), rec.getType());
} else {
log.warn("Record {} of the type {} was not deleted.", rec.getName(), rec.getType());
log.warn("Record {} of the type [{}] was not deleted.", rec.getName(), rec.getType());
}
return changed;
}
@@ -35,13 +35,41 @@ public class CfClientTest {
assumeTrue(API_KEY != null && !API_KEY.isBlank(), "API_KEY not set; skipping pen tests");
}
@Test
void testAddHost() throws Exception {
ZoneEntity zone = client.zoneInfo(ZONE_STR);
RecordEntity record = RecordEntity.build(SLD_STR, RecordType.A, TTL, "127.0.0.1");
RecordEntity createdRecord = client.recordCreate(zone, record);
assertNotNull(createdRecord.getId());
assertEquals(SLD_STR, createdRecord.getName());
assertEquals(RecordType.A.getType(), createdRecord.getType());
assertEquals(TTL, createdRecord.getTtl());
assertEquals("127.0.0.1", createdRecord.getContent());
assertNotNull(createdRecord.getCreatedOn());
client.recordDeleteTypeIfExists(zone, SLD_STR, RecordType.A);
assertThrows(CloudflareNotFoundException.class,
() -> client.sldInfo(zone, SLD_STR, RecordType.A));
record = RecordEntity.build(SLD_STR + "." + ZONE_STR, RecordType.A, TTL, "127.1.0.1");
createdRecord = client.recordCreate(zone, record);
assertNotNull(createdRecord.getId());
assertEquals(SLD_STR, createdRecord.getName());
assertEquals(RecordType.A.getType(), createdRecord.getType());
assertEquals(TTL, createdRecord.getTtl());
assertEquals("127.1.0.1", createdRecord.getContent());
assertNotNull(createdRecord.getCreatedOn());
client.recordDeleteTypeIfExists(zone, SLD_STR, RecordType.A);
}
@Test
void testZoneListAnlFailedSldList() throws Exception {
List<ZoneEntity> zList = client.zoneListAll();
assertEquals(1, zList.size());
assertThrows(CloudflareNotFoundException.class,
() -> client.sldListAll(zList.get(0), "not-existing"));
() -> client.sldListAll(zList.get(0), "not-existing"));
}
@Test