Explorar o código

feat(api): adds test replacing existing RRset with CNAME RRset

This is expected to fail the tests, see #220.
Nils Wisiol %!s(int64=6) %!d(string=hai) anos
pai
achega
b3028aa903
Modificáronse 1 ficheiros con 44 adicións e 0 borrados
  1. 44 0
      test/e2e/spec/api_spec.js

+ 44 - 0
test/e2e/spec/api_spec.js

@@ -517,6 +517,8 @@ describe("API v1", function () {
                                 {'subname': 'a.2', 'ttl': 50, 'type': 'TXT', 'records': ['"foo"']},
                                 {'subname': 'c.2', 'ttl': 50, 'type': 'TXT', 'records': ['"foo"']},
                                 {'subname': 'delete-test', 'ttl': 50, 'type': 'A', 'records': ['127.1.2.3']},
+                                {'subname': 'replace-test-1', 'ttl': 50, 'type': 'AAAA', 'records': ['::1', '::2']},
+                                {'subname': 'replace-test-2', 'ttl': 50, 'type': 'AAAA', 'records': ['::1', '::2']},
                             ]
                         );
                         return expect(response).to.have.status(201);
@@ -535,6 +537,48 @@ describe("API v1", function () {
                         itShowsUpInPdnsAs('delete-test', domain, 'A', []);
                     });
 
+                    describe("can be replaced with a CNAME record", function () {
+                        before(function () {
+                            var response = chakram.put(
+                                '/domains/' + domain + '/rrsets/',
+                                [
+                                    {'subname': 'replace-test-1', 'ttl': 50, 'type': 'AAAA', 'records': []},
+                                    {'subname': 'replace-test-1', 'ttl': 1, 'type': 'CNAME', 'records': ['example.com.']},
+                                ]
+                            );
+                            return expect(response).to.have.status(200);
+                        });
+
+                        itPropagatesToTheApi([
+                            {subname: 'replace-test-1', domain: domain, type: 'AAAA', records: []},
+                            {subname: 'replace-test-1', domain: domain, type: 'CNAME', records: ["example.com."]},
+                        ]);
+
+                        itShowsUpInPdnsAs('replace-test-1', domain, 'AAAA', ["example.com"]);
+                        itShowsUpInPdnsAs('replace-test-1', domain, 'CNAME', ["example.com"]);
+                    });
+
+                    describe("cannot be replaced with a malformed CNAME record", function () {
+                        before(function () {
+                            var response = chakram.put(
+                                '/domains/' + domain + '/rrsets/',
+                                [
+                                    {'subname': 'replace-test-2', 'ttl': 50, 'type': 'AAAA', 'records': []},
+                                    {'subname': 'replace-test-2', 'ttl': 1, 'type': 'CNAME', 'records': ['no.trailing.dot']},
+                                ]
+                            );
+                            return expect(response).to.have.status(422);
+                        });
+
+                        itPropagatesToTheApi([
+                            {subname: 'replace-test-2', domain: domain, type: 'AAAA', records: ["::1", "::2"]},
+                            {subname: 'replace-test-2', domain: domain, type: 'CNAME', records: []},
+                        ]);
+
+                        itShowsUpInPdnsAs('replace-test-2', domain, 'AAAA', ["::1", "::2"]);
+                        itShowsUpInPdnsAs('replace-test-2', domain, 'CNAME', []);
+                    });
+
                     describe("cannot bulk-post existing or duplicate RRsets", function () {
                         var response;