aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/_test
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2022-06-24 14:11:20 +0200
committerAndreas Gohr <andi@splitbrain.org>2022-06-24 14:11:20 +0200
commitb1d4a6675234ece9cddbb606880e112091d22eb5 (patch)
treee86579d89cd7a110e46ab0357988cde7d9efe2e7 /_test
parent047b3cae562e5728fddd50935f66567bbeef6904 (diff)
downloaddokuwiki-b1d4a6675234ece9cddbb606880e112091d22eb5.tar.gz
dokuwiki-b1d4a6675234ece9cddbb606880e112091d22eb5.zip
throw exceptions in API on user creation errors
As discussed in #3609
Diffstat (limited to '_test')
-rw-r--r--_test/tests/inc/remoteapicore_createuser.test.php42
1 files changed, 41 insertions, 1 deletions
diff --git a/_test/tests/inc/remoteapicore_createuser.test.php b/_test/tests/inc/remoteapicore_createuser.test.php
index 317e2b64a..cd51d0c94 100644
--- a/_test/tests/inc/remoteapicore_createuser.test.php
+++ b/_test/tests/inc/remoteapicore_createuser.test.php
@@ -116,7 +116,47 @@ class remoteapicore_createuser_test extends DokuWikiTest {
],
];
- $this->assertFalse($this->remote->call('dokuwiki.createUser', $params));
+ $this->expectException(RemoteException::class);
+ $this->expectExceptionCode(401);
+ $this->remote->call('dokuwiki.createUser', $params);
+ }
+
+ public function test_createUserAuthPlainUndefinedName()
+ {
+ global $conf, $auth;
+ $conf['remote'] = 1;
+ $conf['remoteuser'] = 'testuser';
+ $_SERVER['REMOTE_USER'] = 'testuser';
+ $auth = new auth_plugin_authplain();
+ $params = [
+ [
+ 'user' => 'hello'
+ ],
+ ];
+
+ $this->expectException(RemoteException::class);
+ $this->expectExceptionCode(402);
+ $this->remote->call('dokuwiki.createUser', $params);
+ }
+
+ public function test_createUserAuthPlainBadEmail()
+ {
+ global $conf, $auth;
+ $conf['remote'] = 1;
+ $conf['remoteuser'] = 'testuser';
+ $_SERVER['REMOTE_USER'] = 'testuser';
+ $auth = new auth_plugin_authplain();
+ $params = [
+ [
+ 'user' => 'hello',
+ 'name' => 'A new user',
+ 'mail' => 'this is not an email address'
+ ],
+ ];
+
+ $this->expectException(RemoteException::class);
+ $this->expectExceptionCode(403);
+ $this->remote->call('dokuwiki.createUser', $params);
}
public function test_createUserAuthCanNotDoAddUser()