summaryrefslogtreecommitdiffstats
path: root/ipatests/test_smartproxy/test_host.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2013-12-03 09:14:00 -0700
committerRob Crittenden <rcritten@redhat.com>2014-02-27 15:50:37 -0500
commit4facb9d8ceea6ffe07297f375bf05d9c72bc6125 (patch)
tree44bd9f9645f87dccd84da37ccae0e2c109cd64c3 /ipatests/test_smartproxy/test_host.py
parentadcd373931c50d91550f6b74b191d08ecce5b137 (diff)
downloadfreeipa.git-4facb9d8ceea6ffe07297f375bf05d9c72bc6125.tar.gz
freeipa.git-4facb9d8ceea6ffe07297f375bf05d9c72bc6125.tar.xz
freeipa.git-4facb9d8ceea6ffe07297f375bf05d9c72bc6125.zip
Implement an IPA Foreman smartproxy serverHEADmaster
This currently server supports only host and hostgroup commands for retrieving, adding and deleting entries. The incoming requests are completely unauthenticated and by default requests must be local. Utilize GSS-Proxy to manage the TGT. Configuration information is in the ipa-smartproxy man page. Design: http://www.freeipa.org/page/V3/Smart_Proxy
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={},
+ ),
+
+ ]