123 lines
4.3 KiB
Diff
123 lines
4.3 KiB
Diff
From caacccc6b92c08f510fba2e31d9c56eb372abddc Mon Sep 17 00:00:00 2001
|
|
From: Florence Blanc-Renaud <flo@redhat.com>
|
|
Date: Wed, 19 Jul 2023 13:28:43 +0200
|
|
Subject: [PATCH] xmlrpc tests: add a test for user plugin with non-existing
|
|
idp
|
|
|
|
Add new tests checking the error returned for
|
|
ipa user-add ... --idp nonexistingidp
|
|
ipa user-mod ... --idp nonexistingidp
|
|
ipa stageuser-add ... --idp nonexistingidp
|
|
ipa stageuser-mod ... --idp nonexistingidp
|
|
|
|
The expected error message is:
|
|
ipa: ERROR: External IdP configuration nonexistingidp not found
|
|
|
|
Related: https://pagure.io/freeipa/issue/9416
|
|
|
|
Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
|
|
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
|
|
---
|
|
ipatests/test_xmlrpc/test_stageuser_plugin.py | 20 +++++++++++++++
|
|
ipatests/test_xmlrpc/test_user_plugin.py | 25 +++++++++++++++++++
|
|
2 files changed, 45 insertions(+)
|
|
|
|
diff --git a/ipatests/test_xmlrpc/test_stageuser_plugin.py b/ipatests/test_xmlrpc/test_stageuser_plugin.py
|
|
index 394015f87f9f4bd275a15bab930e28f16b299274..9ae5561dfa4e0d54fe1231501bfea3c0ba261849 100644
|
|
--- a/ipatests/test_xmlrpc/test_stageuser_plugin.py
|
|
+++ b/ipatests/test_xmlrpc/test_stageuser_plugin.py
|
|
@@ -39,6 +39,8 @@ gid = u'456'
|
|
invalidrealm1 = u'suser1@NOTFOUND.ORG'
|
|
invalidrealm2 = u'suser1@BAD@NOTFOUND.ORG'
|
|
|
|
+nonexistentidp = 'IdPDoesNotExist'
|
|
+
|
|
invaliduser1 = u'+tuser1'
|
|
invaliduser2 = u'tuser1234567890123456789012345678901234567890'
|
|
|
|
@@ -431,6 +433,15 @@ class TestCreateInvalidAttributes(XMLRPC_test):
|
|
invalidrealm2))):
|
|
command()
|
|
|
|
+ def test_create_invalid_idp(self, stageduser):
|
|
+ stageduser.ensure_missing()
|
|
+ command = stageduser.make_create_command(
|
|
+ options={u'ipaidpconfiglink': nonexistentidp})
|
|
+ with raises_exact(errors.NotFound(
|
|
+ reason="External IdP configuration {} not found".format(
|
|
+ nonexistentidp))):
|
|
+ command()
|
|
+
|
|
|
|
@pytest.mark.tier1
|
|
class TestUpdateInvalidAttributes(XMLRPC_test):
|
|
@@ -466,6 +477,15 @@ class TestUpdateInvalidAttributes(XMLRPC_test):
|
|
message=u'invalid \'gidnumber\': must be at least 1')):
|
|
command()
|
|
|
|
+ def test_update_invalididp(self, stageduser):
|
|
+ stageduser.ensure_exists()
|
|
+ command = stageduser.make_update_command(
|
|
+ updates={u'ipaidpconfiglink': nonexistentidp})
|
|
+ with raises_exact(errors.NotFound(
|
|
+ reason="External IdP configuration {} not found".format(
|
|
+ nonexistentidp))):
|
|
+ command()
|
|
+
|
|
|
|
@pytest.mark.tier1
|
|
class TestActive(XMLRPC_test):
|
|
diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py
|
|
index 8ac19a4f9ce4f341838282ecd3ed1bb491ac7004..baa28672e7552140a703ecdfa5772b445298cb37 100644
|
|
--- a/ipatests/test_xmlrpc/test_user_plugin.py
|
|
+++ b/ipatests/test_xmlrpc/test_user_plugin.py
|
|
@@ -86,6 +86,8 @@ expired_expiration_string = "1991-12-07T19:54:13Z"
|
|
# Date in ISO format (2013-12-10T12:00:00)
|
|
isodate_re = re.compile(r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$')
|
|
|
|
+nonexistentidp = 'IdPDoesNotExist'
|
|
+
|
|
|
|
@pytest.fixture(scope='class')
|
|
def user_min(request, xmlrpc_setup):
|
|
@@ -542,6 +544,18 @@ class TestUpdate(XMLRPC_test):
|
|
command()
|
|
user.delete()
|
|
|
|
+ def test_update_invalid_idp(self, user):
|
|
+ """ Test user-mod --idp with a non-existent idp """
|
|
+ user.ensure_exists()
|
|
+ command = user.make_update_command(
|
|
+ updates=dict(ipaidpconfiglink=nonexistentidp)
|
|
+ )
|
|
+ with raises_exact(errors.NotFound(
|
|
+ reason="External IdP configuration {} not found".format(
|
|
+ nonexistentidp)
|
|
+ )):
|
|
+ command()
|
|
+
|
|
|
|
@pytest.mark.tier1
|
|
class TestCreate(XMLRPC_test):
|
|
@@ -770,6 +784,17 @@ class TestCreate(XMLRPC_test):
|
|
user_radius.check_create(result)
|
|
user_radius.delete()
|
|
|
|
+ def test_create_with_invalididp(self):
|
|
+ testuser = UserTracker(
|
|
+ name='idpuser', givenname='idp', sn='user',
|
|
+ ipaidpconfiglink=nonexistentidp
|
|
+ )
|
|
+ with raises_exact(errors.NotFound(
|
|
+ reason="External IdP configuration {} not found".format(
|
|
+ nonexistentidp)
|
|
+ )):
|
|
+ testuser.create()
|
|
+
|
|
|
|
@pytest.mark.tier1
|
|
class TestUserWithGroup(XMLRPC_test):
|
|
--
|
|
2.41.0
|
|
|