summaryrefslogtreecommitdiffstats
path: root/ipatests/test_smartproxy/test_host.py
diff options
context:
space:
mode:
Diffstat (limited to 'ipatests/test_smartproxy/test_host.py')
-rw-r--r--ipatests/test_smartproxy/test_host.py145
1 files changed, 145 insertions, 0 deletions
diff --git a/ipatests/test_smartproxy/test_host.py b/ipatests/test_smartproxy/test_host.py
new file mode 100644
index 00000000..6dc90de5
--- /dev/null
+++ b/ipatests/test_smartproxy/test_host.py
@@ -0,0 +1,145 @@
+# Authors:
+# Rob Crittenden <rcritten@redhat.com>
+#
+# Copyright (C) 2014 Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from ipalib import api
+from ipapython.dn import DN
+from resttest import REST_test, fuzzy_uuid, fuzzy_password
+from ipatests.test_xmlrpc import objectclasses
+import requests
+
+fqdn1 = u'testhost.example.com'
+dn1 = DN(('fqdn',fqdn1),('cn','computers'),('cn','accounts'),
+ api.env.basedn)
+fqdn2 = u'testhost2.example.com'
+dn2 = DN(('fqdn',fqdn2),('cn','computers'),('cn','accounts'),
+ api.env.basedn)
+
+class test_host(REST_test):
+
+ cleanup = [
+ ('/ipa/smartproxy/host/%s' % fqdn1, {}),
+ ('/ipa/smartproxy/host/%s' % fqdn2, {}),
+ ]
+
+ tests = [
+
+ dict(
+ desc='Get a non-existent host',
+ request=('/ipa/smartproxy/host/notfound', {}),
+ method=requests.get,
+ expected_status=404,
+ expected={},
+ ),
+
+ dict(
+ desc='Create a host',
+ request=('/ipa/smartproxy/host', {'hostname': fqdn1}),
+ method=requests.post,
+ expected_status=201,
+ expected=dict(
+ dn=dn1,
+ has_keytab=False,
+ krbprincipalname= [u'host/%s@%s' % (fqdn1, api.env.realm)],
+ objectclass=objectclasses.host,
+ fqdn=[fqdn1],
+ has_password=False,
+ ipauniqueid=[fuzzy_uuid],
+ managedby_host=[fqdn1],
+ ),
+ ),
+
+ dict(
+ desc='Get the host',
+ request=('/ipa/smartproxy/host/%s' % fqdn1, {}),
+ method=requests.get,
+ expected_status=200,
+ expected=dict(
+ dn=dn1,
+ has_keytab=False,
+ fqdn=[u'testhost.example.com'],
+ has_password=False,
+ managedby_host=[fqdn1],
+ krbprincipalname=[u'host/%s@%s' % (fqdn1, api.env.realm)],
+ ),
+ ),
+
+ dict(
+ desc='Add a duplicate host',
+ request=('/ipa/smartproxy/host', {'hostname': fqdn1}),
+ method=requests.post,
+ expected_status=400,
+ expected={},
+ ),
+
+ dict(
+ desc='Remove the host',
+ request=('/ipa/smartproxy/host/%s' % fqdn1, {}),
+ method=requests.delete,
+ expected_status=200,
+ expected=dict(failed=u''),
+ ),
+
+ dict(
+ desc='Create a host with a random password',
+ request=('/ipa/smartproxy/host', {'hostname': fqdn1, 'random': True}),
+ method=requests.post,
+ expected_status=201,
+ expected=dict(
+ dn=dn1,
+ has_keytab=False,
+ objectclass=[u'ipasshhost', u'ipaSshGroupOfPubKeys',
+ u'ieee802device', u'ipaobject',
+ u'nshost', u'ipahost', u'pkiuser',
+ u'ipaservice', u'top',],
+ fqdn=[fqdn1],
+ has_password=True,
+ ipauniqueid=[fuzzy_uuid],
+ randompassword=fuzzy_password,
+ managedby_host=[fqdn1],
+ ),
+ ),
+
+ dict(
+ desc='Create a host with a fixed password',
+ request=('/ipa/smartproxy/host', {'hostname': fqdn2, 'password': 'Secret123'}),
+ method=requests.post,
+ expected_status=201,
+ expected=dict(
+ dn=dn2,
+ has_keytab=False,
+ objectclass=[u'ipasshhost', u'ipaSshGroupOfPubKeys',
+ u'ieee802device', u'ipaobject',
+ u'nshost', u'ipahost', u'pkiuser',
+ u'ipaservice', u'top',],
+ fqdn=[fqdn2],
+ has_password=True,
+ ipauniqueid=[fuzzy_uuid],
+ managedby_host=[fqdn2],
+ ),
+ ),
+
+ dict(
+ desc='Remove a non-existent host',
+ request=('/ipa/smartproxy/host/notfound', {}),
+ method=requests.delete,
+ expected_status=404,
+ expected={},
+ ),
+
+ ]