Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/user_saml.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2019-09-19 15:07:21 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2019-09-19 16:16:46 +0300
commit89da6ce72d9e4c5b676458eee5b8747a40175a33 (patch)
tree2a5eb7195b0d8626502131b4c54e1b1d2b1a87b3 /tests
parentc839dc1e73fe10c20e44c2c80347d67480c6efb1 (diff)
add unit tests
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/Controller/SAMLControllerTest.php11
-rw-r--r--tests/unit/UserBackendTest.php20
2 files changed, 27 insertions, 4 deletions
diff --git a/tests/unit/Controller/SAMLControllerTest.php b/tests/unit/Controller/SAMLControllerTest.php
index 903732b9..952e24b6 100644
--- a/tests/unit/Controller/SAMLControllerTest.php
+++ b/tests/unit/Controller/SAMLControllerTest.php
@@ -69,6 +69,9 @@ class SAMLControllerTest extends TestCase {
$this->userSession = $this->createMock(IUserSession::class);
$this->samlSettings = $this->createMock(SAMLSettings::class);
$this->userBackend = $this->createMock(UserBackend::class);
+ $this->userBackend->expects($this->any())
+ ->method('testEncodedObjectGUID')
+ ->willReturnArgument(0);
$this->config = $this->createMock(IConfig::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->userManager = $this->createMock(IUserManager::class);
@@ -275,11 +278,11 @@ class SAMLControllerTest extends TestCase {
->with('/')
->willReturn('https://nextcloud.com/absolute/');
$this->userBackend
- ->expects($this->at(0))
+ ->expects($this->once())
->method('autoprovisionAllowed')
->willReturn(true);
$this->userBackend
- ->expects($this->at(1))
+ ->expects($this->once())
->method('createUserIfNotExists')
->with('MyUid');
$this->userBackend
@@ -332,11 +335,11 @@ class SAMLControllerTest extends TestCase {
->with('user_saml.SAML.notProvisioned')
->willReturn('https://nextcloud.com/notprovisioned/');
$this->userBackend
- ->expects($this->at(0))
+ ->expects($this->once())
->method('autoprovisionAllowed')
->willReturn(true);
$this->userBackend
- ->expects($this->at(1))
+ ->expects($this->once())
->method('createUserIfNotExists')
->with('MyUid');
$this->userBackend
diff --git a/tests/unit/UserBackendTest.php b/tests/unit/UserBackendTest.php
index e3bc722c..28bd4353 100644
--- a/tests/unit/UserBackendTest.php
+++ b/tests/unit/UserBackendTest.php
@@ -281,5 +281,25 @@ class UserBackendTest extends TestCase {
$this->userBackend->updateAttributes('ExistingUser', ['email' => 'new@example.com', 'displayname' => 'New Displayname', 'quota' => '']);
}
+ public function objectGuidProvider() {
+ return [
+ ['Joey No Conversion', 'Joey No Conversion'],
+ ['no@convers.ion', 'no@convers.ion'],
+ ['a0aa9ed8-6b48-1034-8ad7-8fb78330d80a', 'a0aa9ed8-6b48-1034-8ad7-8fb78330d80a'],
+ ['EDE70D16-B9D5-4E9A-ABD7-614D17246E3F', 'EDE70D16-B9D5-4E9A-ABD7-614D17246E3F'],
+ ['Tm8gY29udmVyc2lvbgo=', 'Tm8gY29udmVyc2lvbgo='],
+ ['ASfjU2OYEd69ZgAVF4pePA==', '53E32701-9863-DE11-BD66-0015178A5E3C'],
+ ];
+ }
+
+ /**
+ * @dataProvider objectGuidProvider
+ */
+ public function testTestEncodedObjectGUID(string $input, string $expectation) {
+ $this->getMockedBuilder(['getDisplayName', 'setDisplayName']);
+ $uid = $this->userBackend->testEncodedObjectGUID($input);
+ $this->assertSame($expectation, $uid);
+ }
+
}