summaryrefslogtreecommitdiffstats
path: root/ipatests/test_xmlrpc/test_location_plugin.py
diff options
context:
space:
mode:
authorMartin Basti <mbasti@redhat.com>2016-05-17 13:08:59 +0200
committerMartin Basti <mbasti@redhat.com>2016-06-03 15:58:21 +0200
commit42719acdcebd3ef939587d4af4c3c6ad743ec601 (patch)
treec5f3eff8b80a74dd99cd2d968ad76acfe23965f1 /ipatests/test_xmlrpc/test_location_plugin.py
parentfd2bd60383a739185a0a67fd0fb43338bab17e1d (diff)
downloadfreeipa-42719acdcebd3ef939587d4af4c3c6ad743ec601.tar.gz
freeipa-42719acdcebd3ef939587d4af4c3c6ad743ec601.tar.xz
freeipa-42719acdcebd3ef939587d4af4c3c6ad743ec601.zip
DNS Locations: extend tests with server-* commands
https://fedorahosted.org/freeipa/ticket/2008 Reviewed-By: Petr Spacek <pspacek@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipatests/test_xmlrpc/test_location_plugin.py')
-rw-r--r--ipatests/test_xmlrpc/test_location_plugin.py91
1 files changed, 89 insertions, 2 deletions
diff --git a/ipatests/test_xmlrpc/test_location_plugin.py b/ipatests/test_xmlrpc/test_location_plugin.py
index 1ca3eac7c..97e97a2bc 100644
--- a/ipatests/test_xmlrpc/test_location_plugin.py
+++ b/ipatests/test_xmlrpc/test_location_plugin.py
@@ -5,12 +5,14 @@ from __future__ import absolute_import
import pytest
-from ipalib import errors
+from ipalib import errors, api
from ipatests.test_xmlrpc.tracker.location_plugin import LocationTracker
+from ipatests.test_xmlrpc.tracker.server_plugin import ServerTracker
from ipatests.test_xmlrpc.xmlrpc_test import (
XMLRPC_test,
raises_exact,
)
+from ipapython.dnsutil import DNSName
@pytest.fixture(scope='class', params=[u'location1', u'sk\xfa\u0161ka.idna'])
@@ -31,6 +33,12 @@ def location_absolute(request):
return tracker.make_fixture(request)
+@pytest.fixture(scope='class')
+def server(request):
+ tracker = ServerTracker(api.env.host)
+ return tracker
+
+
@pytest.mark.tier1
class TestNonexistentIPALocation(XMLRPC_test):
def test_retrieve_nonexistent(self, location):
@@ -75,7 +83,7 @@ class TestInvalidIPALocations(XMLRPC_test):
class TestCRUD(XMLRPC_test):
def test_create_duplicate(self, location):
location.ensure_exists()
- command = location.make_create_command(force=True)
+ command = location.make_create_command()
with raises_exact(errors.DuplicateEntry(
message=u'location with name "%s" already exists' %
location.idnsname)):
@@ -111,3 +119,82 @@ class TestCRUD(XMLRPC_test):
def test_delete_location(self, location):
location.delete()
+
+
+@pytest.mark.tier1
+class TestLocationsServer(XMLRPC_test):
+
+ def test_add_nonexistent_location_to_server(self, server):
+ nonexistent_loc = DNSName(u'nonexistent-location')
+ command = server.make_update_command(
+ updates=dict(
+ ipalocation_location=nonexistent_loc,
+ )
+ )
+ with raises_exact(errors.NotFound(
+ reason=u"{location}: location not found".format(
+ location=nonexistent_loc
+ ))):
+ command()
+
+ def test_add_location_to_server(self, location, server):
+ location.ensure_exists()
+ server.update(
+ dict(ipalocation_location=location.idnsname_obj),
+ expected_updates=dict(
+ ipalocation_location=[location.idnsname_obj],
+ )
+ )
+ location.add_server_to_location(server.server_name)
+ location.retrieve()
+
+ def test_retrieve(self, server):
+ server.retrieve()
+
+ def test_retrieve_all(self, server):
+ server.retrieve(all=True)
+
+ def test_search_server_with_location(self, location, server):
+ command = server.make_find_command(
+ server.server_name, in_location=location.idnsname_obj)
+ result = command()
+ server.check_find(result)
+
+ def test_search_server_with_location_with_all(self, location, server):
+ command = server.make_find_command(
+ server.server_name, in_location=location.idnsname_obj, all=True)
+ result = command()
+ server.check_find(result, all=True)
+
+ def test_search_server_without_location(self, location, server):
+ command = server.make_find_command(
+ server.server_name, not_in_location=location.idnsname_obj)
+ result = command()
+ server.check_find_nomatch(result)
+
+ def test_add_location_to_server_custom_weight(self, location, server):
+ location.ensure_exists()
+ server.update(
+ dict(
+ ipalocation_location=location.idnsname_obj,
+ ipalocationweight=200,
+ ),
+ expected_updates=dict(
+ ipalocation_location=[location.idnsname_obj],
+ ipalocationweight=[u'200'],
+ )
+ )
+ # remove invalid data from the previous test
+ location.remove_server_from_location(server.server_name)
+
+ location.add_server_to_location(server.server_name, weight=200)
+ location.retrieve()
+
+ def test_remove_location_from_server(self, location, server):
+ server.update(dict(ipalocation_location=None))
+ location.remove_server_from_location(server.server_name)
+ location.retrieve()
+
+ def test_remove_location_weight_from_server(self, location, server):
+ server.update(dict(ipalocationweight=None))
+ location.retrieve()