summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2014-12-12 14:04:10 +0100
committerPetr Vobornik <pvoborni@redhat.com>2014-12-12 14:06:07 +0100
commitc2c3defdde9f79da57a7bed45c956cd7086e5d2b (patch)
tree51bff7598fef33112b6edd9a61cff651a0f7c6f8
parent9dd32238aa12131cc833ce1e903445bb94c6aaec (diff)
downloadfreeipa-otptests.tar.gz
freeipa-otptests.tar.xz
freeipa-otptests.zip
try to use forms based auth in tests - an EXAMPLEotptests
-rw-r--r--ipatests/test_webui/test_otptoken.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/ipatests/test_webui/test_otptoken.py b/ipatests/test_webui/test_otptoken.py
index 151cfb0b0..2afd8f9c4 100644
--- a/ipatests/test_webui/test_otptoken.py
+++ b/ipatests/test_webui/test_otptoken.py
@@ -24,6 +24,17 @@ OTP Token Tests
from ipatests.test_webui.ui_driver import UI_driver
from ipatests.test_webui.ui_driver import screenshot
import ipatests.test_webui.data_user as user
+from ipatests.util import get_api
+from ipalib.rpc import jsonclient
+from ipalib import api
+from ipapython import ipautil
+import json
+from ipapython.ipautil import run
+from ipapython import certdb
+from ipalib import x509, certstore
+from ipaplatform.paths import paths
+from urllib2 import urlparse
+
ENTITY = 'otptoken'
@@ -145,3 +156,46 @@ class test_otptoken(UI_driver):
)
print self.config_uri
self.rpc(user.ENTITY + '_del', [uid], { 'continue': True })
+
+ def _prepare_nss_dir(self, ipa_server):
+ """
+ Create temporary NSS Database with IPA server CA cert
+ """
+
+ # create new NSSDatabase
+ tmp_db = certdb.NSSDatabase()
+ pwd_file = ipautil.write_tmp_file(ipautil.ipa_generate_password())
+ tmp_db.create_db(pwd_file.name)
+
+ # download and add cert
+ url = urlparse.urlunparse(('http', ipautil.format_netloc(ipa_server),
+ '/ipa/config/ca.crt', '', '', ''))
+ stdout, stderr, rc = run([paths.BIN_WGET, "-O", "-", url])
+ certs = x509.load_certificate_list(stdout, tmp_db.secdir)
+ ca_certs = [cert.der_data for cert in certs]
+ for i, cert in enumerate(ca_certs):
+ tmp_db.add_cert(cert, 'CA certificate %d' % (i + 1), 'C,,')
+
+ return tmp_db
+
+ def test_rpc(self):
+
+ ipa_server = self.config['ipa_server']
+ tmp_cert_db = self._prepare_nss_dir(ipa_server)
+
+ api.bootstrap(
+ context='webui_tests',
+ in_server=False,
+ debug=False,
+ verbose=1,
+ xmlrpc_uri="https://" + ipa_server + "/ipa/json",
+ )
+ api.finalize()
+ api.Backend.rpcclient.connect(
+ nss_dir=tmp_cert_db.secdir,
+ user=u"admin",
+ password=u"Secret123"
+ )
+ result = api.Command.user_show(u'admin')
+ print json.dumps(result)
+ assert False