aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Authentication/Token/PublicKeyTokenTest.php
blob: cc8890002e914f0889a38a6e1619283fc4e8405a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

declare(strict_types=1);
/**
 * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace Test\Authentication\Token;

use OC\Authentication\Token\PublicKeyToken;
use OCP\Authentication\Token\IToken;
use Test\TestCase;

class PublicKeyTokenTest extends TestCase {
	public function testSetScopeAsArray() {
		$scope = [IToken::SCOPE_FILESYSTEM => false];
		$token = new PublicKeyToken();
		$token->setScope($scope);
		$this->assertEquals(json_encode($scope), $token->getScope());
		$this->assertEquals($scope, $token->getScopeAsArray());
	}

	public function testDefaultScope() {
		$scope = [IToken::SCOPE_FILESYSTEM => true];
		$token = new PublicKeyToken();
		$this->assertEquals($scope, $token->getScopeAsArray());
	}
}