Skip to content

Commit 9d0884a

Browse files
committed
add marvin test for powerdns
1 parent 6466362 commit 9d0884a

9 files changed

Lines changed: 335 additions & 22 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,6 @@ public class ApiConstants {
13511351
// DNS provider related
13521352
public static final String NAME_SERVERS = "nameservers";
13531353
public static final String DNS_USER_NAME = "dnsusername";
1354-
public static final String CREDENTIALS = "credentials";
13551354
public static final String DNS_ZONE_ID = "dnszoneid";
13561355
public static final String DNS_ZONE = "dnszone";
13571356
public static final String DNS_RECORD = "dnsrecord";

api/src/main/java/org/apache/cloudstack/api/command/user/dns/AddDnsServerCmd.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public class AddDnsServerCmd extends BaseCmd {
6262
description = "Username or email associated with the external DNS provider account (used for authentication)")
6363
private String dnsUserName;
6464

65-
@Parameter(name = ApiConstants.CREDENTIALS, required = true, type = CommandType.STRING, description = "API key or credentials for the external provider")
66-
private String credentials;
65+
@Parameter(name = ApiConstants.API_KEY, required = true, type = CommandType.STRING, description = "API key or token for the external provider")
66+
private String apiKey;
6767

6868
@Parameter(name = ApiConstants.PORT, type = CommandType.INTEGER, description = "Port number of the external DNS server")
6969
private Integer port;
@@ -89,8 +89,8 @@ public class AddDnsServerCmd extends BaseCmd {
8989

9090
public String getUrl() { return url; }
9191

92-
public String getCredentials() {
93-
return credentials;
92+
public String getApiKey() {
93+
return apiKey;
9494
}
9595

9696
public Integer getPort() {

api/src/main/java/org/apache/cloudstack/api/command/user/dns/UpdateDnsServerCmd.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public class UpdateDnsServerCmd extends BaseCmd {
5858
@Parameter(name = ApiConstants.URL, type = CommandType.STRING, description = "API URL of the provider")
5959
private String url;
6060

61-
@Parameter(name = ApiConstants.CREDENTIALS, type = CommandType.STRING, required = false, description = "API Key or Credentials for the external provider")
62-
private String credentials;
61+
@Parameter(name = ApiConstants.API_KEY, type = CommandType.STRING, required = false, description = "API Key or Credentials for the external provider")
62+
private String apiKey;
6363

6464
@Parameter(name = ApiConstants.PORT, type = CommandType.INTEGER, description = "Port number of the external DNS server")
6565
private Integer port;
@@ -83,8 +83,8 @@ public class UpdateDnsServerCmd extends BaseCmd {
8383
public Long getId() { return id; }
8484
public String getName() { return name; }
8585
public String getUrl() { return url; }
86-
public String getCredentials() {
87-
return credentials;
86+
public String getApiKey() {
87+
return apiKey;
8888
}
8989
public Integer getPort() {
9090
return port;

api/src/test/java/org/apache/cloudstack/api/command/user/dns/AddDnsServerCmdTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private AddDnsServerCmd createCmd() throws Exception {
4040
setField(cmd, "name", "test-dns");
4141
setField(cmd, "url", "http://dns.example.com");
4242
setField(cmd, "provider", "PowerDNS");
43-
setField(cmd, "credentials", "api-key-123");
43+
setField(cmd, "apiKey", "api-key-123");
4444
setField(cmd, "port", 8081);
4545
setField(cmd, "isPublic", true);
4646
setField(cmd, "publicDomainSuffix", "public.example.com");
@@ -56,7 +56,7 @@ public void testAccessors() throws Exception {
5656

5757
assertEquals("test-dns", cmd.getName());
5858
assertEquals("http://dns.example.com", cmd.getUrl());
59-
assertEquals("api-key-123", cmd.getCredentials());
59+
assertEquals("api-key-123", cmd.getApiKey());
6060
assertEquals(Integer.valueOf(8081), cmd.getPort());
6161
assertTrue(cmd.isPublic());
6262
assertEquals("public.example.com", cmd.getPublicDomainSuffix());

api/src/test/java/org/apache/cloudstack/api/command/user/dns/UpdateDnsServerCmdTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private UpdateDnsServerCmd createCmd() throws Exception {
3939
setField(cmd, "id", ENTITY_ID);
4040
setField(cmd, "name", "updated-dns");
4141
setField(cmd, "url", "http://updated.dns.com");
42-
setField(cmd, "credentials", "new-api-key");
42+
setField(cmd, "apiKey", "new-api-key");
4343
setField(cmd, "port", 9090);
4444
setField(cmd, "isPublic", true);
4545
setField(cmd, "publicDomainSuffix", "updated.example.com");
@@ -55,7 +55,7 @@ public void testAccessors() throws Exception {
5555
assertEquals(Long.valueOf(ENTITY_ID), cmd.getId());
5656
assertEquals("updated-dns", cmd.getName());
5757
assertEquals("http://updated.dns.com", cmd.getUrl());
58-
assertEquals("new-api-key", cmd.getCredentials());
58+
assertEquals("new-api-key", cmd.getApiKey());
5959
assertEquals(Integer.valueOf(9090), cmd.getPort());
6060
assertTrue(cmd.isPublic());
6161
assertEquals("updated.example.com", cmd.getPublicDomainSuffix());

engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ CREATE TABLE IF NOT EXISTS `cloud`.`dns_server` (
131131
`provider_type` varchar(255) NOT NULL COMMENT 'Provider type such as PowerDns',
132132
`url` varchar(1024) NOT NULL COMMENT 'dns server url',
133133
`dns_username` varchar(255) COMMENT 'username or email for dns server credentials',
134-
`api_key` varchar(255) NOT NULL COMMENT 'dns server api_key',
134+
`api_key` varchar(255) NOT NULL COMMENT 'api key or token for the dns server ',
135135
`external_server_id` varchar(255) COMMENT 'dns server id e.g. localhost for powerdns',
136136
`port` int(11) DEFAULT NULL COMMENT 'optional dns server port',
137137
`name_servers` varchar(1024) DEFAULT NULL COMMENT 'Comma separated list of name servers',
@@ -186,7 +186,3 @@ CREATE TABLE IF NOT EXISTS `cloud`.`dns_zone_network_map` (
186186
CONSTRAINT `fk_dns_map__zone_id` FOREIGN KEY (`dns_zone_id`) REFERENCES `dns_zone` (`id`) ON DELETE CASCADE,
187187
CONSTRAINT `fk_dns_map__network_id` FOREIGN KEY (`network_id`) REFERENCES `networks` (`id`) ON DELETE CASCADE
188188
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
189-
190-
-- Set default limit to 10 DNS zones for standard Accounts
191-
INSERT INTO `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `value`, `description`, `default_value`)
192-
VALUES ('Advanced', 'DEFAULT', 'ResourceLimitManager', 'max.account.dns_zones', '10', 'The default maximum number of DNS zones that can be created by an Account', '10');

server/src/main/java/org/apache/cloudstack/dns/DnsProviderManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public DnsServer addDnsServer(AddDnsServerCmd cmd) {
177177

178178
DnsProviderType type = cmd.getProvider();
179179
DnsServerVO server = new DnsServerVO(cmd.getName(), cmd.getUrl(), cmd.getPort(), cmd.getExternalServerId(), type,
180-
cmd.getDnsUserName(), cmd.getCredentials(), isDnsPublic, publicDomainSuffix, cmd.getNameServers(),
180+
cmd.getDnsUserName(), cmd.getApiKey(), isDnsPublic, publicDomainSuffix, cmd.getNameServers(),
181181
caller.getAccountId(), caller.getDomainId());
182182
try {
183183
DnsProvider provider = getProviderByType(type);
@@ -250,8 +250,8 @@ public DnsServer updateDnsServer(UpdateDnsServerCmd cmd) {
250250
}
251251
}
252252

253-
if (cmd.getCredentials() != null && !cmd.getCredentials().equals(originalKey)) {
254-
dnsServer.setApiKey(cmd.getCredentials());
253+
if (cmd.getApiKey() != null && !cmd.getApiKey().equals(originalKey)) {
254+
dnsServer.setApiKey(cmd.getApiKey());
255255
validationRequired = true;
256256
}
257257

server/src/test/java/org/apache/cloudstack/dns/DnsProviderManagerImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ public void testUpdateDnsServerValidationException() throws Exception {
849849
org.apache.cloudstack.api.command.user.dns.UpdateDnsServerCmd cmd = mock(
850850
org.apache.cloudstack.api.command.user.dns.UpdateDnsServerCmd.class);
851851
when(cmd.getId()).thenReturn(SERVER_ID);
852-
when(cmd.getCredentials()).thenReturn("new-api-key");
852+
when(cmd.getApiKey()).thenReturn("new-api-key");
853853

854854
when(dnsServerDao.findById(SERVER_ID)).thenReturn(serverVO);
855855
Mockito.doReturn("old-api-key").when(serverVO).getApiKey();

0 commit comments

Comments
 (0)