Example #1
0
def test_list_zone_changes(mocked_responses, vinyldns_client):
    change1 = ZoneChange(zone=forward_zone,
                         user_id='some-user',
                         change_type='Create',
                         status='Pending',
                         created=datetime.utcnow(),
                         system_message=None,
                         id='zone-change-id1')
    change2 = ZoneChange(zone=ip4_zone,
                         user_id='some-user',
                         change_type='Create',
                         status='Pending',
                         created=datetime.utcnow(),
                         system_message='msg',
                         id='zone-change-id2')
    lzcr = ListZoneChangesResponse(forward_zone.id, [change1, change2], 'next',
                                   'start', 100)
    mocked_responses.add(
        responses.GET,
        'http://test.com/zones/{0}/changes?startFrom=start&maxItems=100'.
        format(forward_zone.id),
        body=to_json_string(lzcr),
        status=200)
    r = vinyldns_client.list_zone_changes(forward_zone.id, 'start', 100)
    assert r.start_from == lzcr.start_from
    assert r.next_id == lzcr.next_id
    assert r.max_items == lzcr.max_items
    for l, r in zip(lzcr.zone_changes, r.zone_changes):
        assert l.id == r.id
        assert l.user_id == r.user_id
        assert l.change_type == r.change_type
        assert l.status == r.status
        assert l.created == r.created
        assert l.system_message == r.system_message
        check_zones_are_same(l.zone, r.zone)
Example #2
0
    def update_zone(self, zone, **kwargs):
        """
        Update a zone.

        :param zone: the zone to be created
        :return: the content of the response
        """
        url = urljoin(self.index_url, u'/zones/{0}'.format(zone.id))
        response, data = self.__make_request(url, u'PUT', self.headers, to_json_string(zone), **kwargs)
        return ZoneChange.from_dict(data)
Example #3
0
    def connect_zone(self, zone, **kwargs):
        """
        Create a new zone with the given name and email.

        :param zone: the zone to be created
        :return: the content of the response
        """
        url = urljoin(self.index_url, u'/zones')
        response, data = self.__make_request(url, u'POST', self.headers, to_json_string(zone), **kwargs)
        return ZoneChange.from_dict(data)
Example #4
0
    def abandon_zone(self, zone_id, **kwargs):
        """
        Delete the zone for the given id.

        :param zone_id: the id of the zone to be deleted
        :return: nothing, will fail if the status code was not expected
        """
        url = urljoin(self.index_url, u'/zones/{0}'.format(zone_id))
        response, data = self.__make_request(url, u'DELETE', self.headers, **kwargs)

        return ZoneChange.from_dict(data)
Example #5
0
    def sync_zone(self, zone_id, **kwargs):
        """
        Sync a zone.

        :param zone: the zone to be updated
        :return: the content of the response
        """
        url = urljoin(self.index_url, u'/zones/{0}/sync'.format(zone_id))
        response, data = self.__make_request(url, u'POST', self.headers, **kwargs)

        return ZoneChange.from_dict(data)
Example #6
0
    def delete_zone_acl_rule(self, zone_id, acl_rule, **kwargs):
        """
        Delete an acl rule from the zone.

        :param zone_id: The id of the zone to remove the acl from
        :param acl_rule: The acl rule to remove
        :return: the content of the response
        """
        url = urljoin(self.index_url, '/zones/{0}/acl/rules'.format(zone_id))
        response, data = self.__make_request(url, 'DELETE', self.headers,
                                             to_json_string(acl_rule), **kwargs)

        return ZoneChange.from_dict(data)
Example #7
0
    def add_zone_acl_rule(self, zone_id, acl_rule, **kwargs):
        """
        Put an acl rule on the zone.

        :param zone_id: The id of the zone to attach the acl rule to
        :param acl_rule: The acl rule contents
        :return: the content of the response
        """
        url = urljoin(self.index_url, '/zones/{0}/acl/rules'.format(zone_id))
        response, data = self.__make_request(url, 'PUT', self.headers,
                                             to_json_string(acl_rule), **kwargs)

        return ZoneChange.from_dict(data)
Example #8
0
                admin_group_id='foo',
                connection=conn,
                transfer_connection=conn,
                acl=ZoneACL([acl_rule]))
ip6_zone = Zone(id='ip6',
                name='1.9.e.f.c.c.7.2.9.6.d.f.ip6.arpa',
                email='*****@*****.**',
                admin_group_id='foo',
                connection=conn,
                transfer_connection=conn,
                acl=ZoneACL([acl_rule]))

sample_zone_change = ZoneChange(zone=forward_zone,
                                user_id='some-user',
                                change_type='Create',
                                status='Pending',
                                created=datetime.utcnow(),
                                system_message=None,
                                id='zone-change-id')

record_sets = {
    RecordType.A:
    RecordSet(forward_zone.id,
              'a-test',
              RecordType.A,
              200,
              records=[AData('1.2.3.4')],
              owner_group_id='owner-group-id'),
    RecordType.AAAA:
    RecordSet(forward_zone.id,
              'aaaa-test',