# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # # Translators: msgid "" msgstr "" "Project-Id-Version: ownCloud\n" "Report-Msgid-Bugs-To: http://bugs.owncloud.org/\n" "POT-Creation-Date: 2013-06-27 02:04+0200\n" "PO-Revision-Date: 2013-06-26 23:14+0000\n" "Last-Translator: I Robot \n" "Language-Team: Georgian (http://www.transifex.com/projects/p/owncloud/language/ka/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: ka\n" "Plural-Forms: nplurals=1; plural=0;\n" #: ajax/move.php:17 #, php-format msgid "Could not move %s - File with this name already exists" msgstr "" #: ajax/move.php:27 ajax/move.php:30 #, php-format msgid "Could not move %s" msgstr "" #: ajax/upload.php:19 msgid "No file was uploaded. Unknown error" msgstr "" #: ajax/upload.php:26 msgid "There is no error, the file uploaded with success" msgstr "" #: ajax/upload.php:27 msgid "" "The uploaded file exceeds the upload_max_filesize directive in php.ini: " msgstr "" #: ajax/upload.php:29 msgid "" "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in " "the HTML form" msgstr "" #: ajax/upload.php:30 msgid "The uploaded file was only partially uploaded" msgstr "" #: ajax/upload.php:31 msgid "No file was uploaded" msgstr "" #: ajax/upload.php:32 msgid "Missing a temporary folder" msgstr "" #: ajax/upload.php:33 msgid "Failed to write to disk" msgstr "" #: ajax/upload.php:51 msgid "Not enough storage available" msgstr "" #: ajax/upload.php:83 msgid "Invalid directory." msgstr "" #: appinfo/app.php:12 msgid "Files" msgstr "ფაილები" #: js/fileactions.js:116 msgid "Share" msgstr "" #: js/fileactions.js:126 msgid "Delete permanently" msgstr "" #: js/fileactions.js:128 templates/index.php:93 templates/index.php:94 msgid "Delete" msgstr "" #: js/fileactions.js:194 msgid "Rename" msgstr "" #: js/filelist.js:49 js/filelist.js:52 js/filelist.js:421 msgid "Pending" msgstr "" #: js/filelist.js:259 js/filelist.js:261 msgid "{new_name} already exists" msgstr "" #: js/filelist.js:259 js/filelist.js:261 msgid "replace" msgstr "" #: js/filelist.js:259 msgid "suggest name" msgstr "" #: js/filelist.js:259 js/filelist.js:261 msgid "cancel" msgstr "" #: js/filelist.js:306 msgid "replaced {new_name} with {old_name}" msgstr "" #: js/filelist.js:306 msgid "undo" msgstr "" #: js/filelist.js:331 msgid "perform delete operation" msgstr "" #: js/filelist.js:413 msgid "1 file uploading" msgstr "" #: js/filelist.js:416 js/filelist.js:470 msgid "files uploading" msgstr "" #: js/files.js:52 msgid "'.' is an invalid file name." msgstr "" #: js/files.js:56 msgid "File name cannot be empty." msgstr "" #: js/files.js:64 msgid "" "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not " "allowed." msgstr "" #: js/files.js:78 msgid "Your storage is full, files can not be updated or synced anymore!" msgstr "" #: js/files.js:82 msgid "Your storage is almost full ({usedSpacePercent}%)" msgstr "" #: js/files.js:231 msgid "" "Your download is being prepared. This might take some time if the files are " "big." msgstr "" #: js/files.js:264 msgid "Unable to upload your file as it is a directory or has 0 bytes" msgstr "" #: js/files.js:277 msgid "Not enough space available" msgstr "" #: js/files.js:317 msgid "Upload cancelled." msgstr "" #: js/files.js:413 msgid "" "File upload is in progress. Leaving the page now will cancel the upload." msgstr "" #: js/files.js:486 msgid "URL cannot be empty." msgstr "" #: js/files.js:491 msgid "Invalid folder name. Usage of 'Shared' is reserved by Owncloud" msgstr "" #: js/files.js:520 js/files.js:536 js/files.js:840 js/files.js:878 msgid "Error" msgstr "" #: js/files.js:891 templates/index.php:69 msgid "Name" msgstr "" #: js/files.js:892 templates/index.php:80 msgid "Size" msgstr "" #: js/files.js:893 templates/index.php:82 msgid "Modified" msgstr "" #: js/files.js:912 msgid "1 folder" msgstr "" #: js/files.js:914 msgid "{count} folders" msgstr "" #: js/files.js:922 msgid "1 file" msgstr "" #: js/files.js:924 msgid "{count} files" msgstr "" #: lib/app.php:53 msgid "Invalid folder name. Usage of 'Shared' is reserved by ownCloud" msgstr "" #: lib/app.php:73 msgid "Unable to rename file" msgstr "" #: lib/helper.php:11 templates/index.php:18 msgid "Upload" msgstr "" #: templates/admin.php:5 msgid "File handling" msgstr "" #: templates/admin.php:7 msgid "Maximum upload size" msgstr "" #: templates/admin.php:10 msgid "max. possible: " msgstr "" #: templates/admin.php:15 msgid "Needed for multi-file and folder downloads." msgstr "" #: templates/admin.php:17 msgid "Enable ZIP-download" msgstr "" #: templates/admin.php:20 msgid "0 is unlimited" msgstr "" #: templates/admin.php:22 msgid "Maximum input size for ZIP files" msgstr "" #: templates/admin.php:26 msgid "Save" msgstr "" #: templates/index.php:7 msgid "New" msgstr "" #: templates/index.php:10 msgid "Text file" msgstr "" #: templates/index.php:12 msgid "Folder" msgstr "" #: templates/index.php:14 msgid "From link" msgstr "" #: templates/index.php:42 msgid "Deleted files" msgstr "" #: templates/index.php:48 msgid "Cancel upload" msgstr "" #: templates/index.php:54 msgid "You don’t have write permissions here." msgstr "" #: templates/index.php:61 msgid "Nothing in here. Upload something!" msgstr "" #: templates/index.php:75 msgid "Download" msgstr "გადმოწერა" #: templates/index.php:87 templates/index.php:88 msgid "Unshare" msgstr "" #: templates/index.php:107 msgid "Upload too large" msgstr "" #: templates/index.php:109 msgid "" "The files you are trying to upload exceed the maximum size for file uploads " "on this server." msgstr "" #: templates/index.php:114 msgid "Files are being scanned, please wait." msgstr "" #: templates/index.php:117 msgid "Current scanning" msgstr "" #: templates/upgrade.php:2 msgid "Upgrading filesystem cache..." msgstr "" cate_propfind_call Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Security/CSRF/CsrfTokenManagerTest.php
blob: 6f7842fdfd9b61952119b44204ee598f12f8abaa (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/**
 * @author Lukas Reschke <lukas@owncloud.com>
 *
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */

namespace Test\Security\CSRF;

class CsrfTokenManagerTest extends \Test\TestCase {
	/** @var \OC\Security\CSRF\CsrfTokenManager */
	private $csrfTokenManager;
	/** @var \OC\Security\CSRF\CsrfTokenGenerator */
	private $tokenGenerator;
	/** @var \OC\Security\CSRF\TokenStorage\SessionStorage */
	private $storageInterface;

	public function setUp() {
		parent::setUp();
		$this->tokenGenerator = $this->getMockBuilder('\OC\Security\CSRF\CsrfTokenGenerator')
			->disableOriginalConstructor()->getMock();
		$this->storageInterface = $this->getMockBuilder('\OC\Security\CSRF\TokenStorage\SessionStorage')
			->disableOriginalConstructor()->getMock();

		$this->csrfTokenManager = new \OC\Security\CSRF\CsrfTokenManager(
			$this->tokenGenerator,
			$this->storageInterface
		);
	}

	public function testGetTokenWithExistingToken() {
		$this->storageInterface
			->expects($this->once())
			->method('hasToken')
			->willReturn(true);
		$this->storageInterface
			->expects($this->once())
			->method('getToken')
			->willReturn('MyExistingToken');

		$expected = new \OC\Security\CSRF\CsrfToken('MyExistingToken');
		$this->assertEquals($expected, $this->csrfTokenManager->getToken());
	}

	public function testGetTokenWithExistingTokenKeepsOnSecondRequest() {
		$this->storageInterface
			->expects($this->once())
			->method('hasToken')
			->willReturn(true);
		$this->storageInterface
			->expects($this->once())
			->method('getToken')
			->willReturn('MyExistingToken');

		$expected = new \OC\Security\CSRF\CsrfToken('MyExistingToken');
		$token = $this->csrfTokenManager->getToken();
		$this->assertSame($token, $this->csrfTokenManager->getToken());
		$this->assertSame($token, $this->csrfTokenManager->getToken());
	}

	public function testGetTokenWithoutExistingToken() {
		$this->storageInterface
			->expects($this->once())
			->method('hasToken')
			->willReturn(false);
		$this->tokenGenerator
			->expects($this->once())
			->method('generateToken')
			->willReturn('MyNewToken');
		$this->storageInterface
			->expects($this->once())
			->method('setToken')
			->with('MyNewToken');

		$expected = new \OC\Security\CSRF\CsrfToken('MyNewToken');
		$this->assertEquals($expected, $this->csrfTokenManager->getToken());
	}

	public function testRefreshToken() {
		$this->tokenGenerator
			->expects($this->once())
			->method('generateToken')
			->willReturn('MyNewToken');
		$this->storageInterface
			->expects($this->once())
			->method('setToken')
			->with('MyNewToken');

		$expected = new \OC\Security\CSRF\CsrfToken('MyNewToken');
		$this->assertEquals($expected, $this->csrfTokenManager->refreshToken());
	}

	public function testRemoveToken() {
		$this->storageInterface
			->expects($this->once())
			->method('removeToken');

		$this->csrfTokenManager->removeToken();
	}

	public function testIsTokenValidWithoutToken() {
		$this->storageInterface
			->expects($this->once())
			->method('hasToken')
			->willReturn(false);
		$token = new \OC\Security\CSRF\CsrfToken('Token');

		$this->assertSame(false, $this->csrfTokenManager->isTokenValid($token));
	}

	public function testIsTokenValidWithWrongToken() {
		$this->storageInterface
			->expects($this->once())
			->method('hasToken')
			->willReturn(true);
		$token = new \OC\Security\CSRF\CsrfToken('Token');
		$this->storageInterface
			->expects($this->once())
			->method('getToken')
			->willReturn('MyToken');

		$this->assertSame(false, $this->csrfTokenManager->isTokenValid($token));
	}

	public function testIsTokenValidWithValidToken() {
		$this->storageInterface
				->expects($this->once())
				->method('hasToken')
				->willReturn(true);
		$token = new \OC\Security\CSRF\CsrfToken('XlQhHjgWCgBXAEI0Khl+IQEiCXN2LUcDHAQTQAc1HQs=:qgkUlg8l3m8WnkOG4XM9Az33pAt1vSVMx4hcJFsxdqc=');
		$this->storageInterface
				->expects($this->once())
				->method('getToken')
				->willReturn('/3JKTq2ldmzcDr1f5zDJ7Wt0lEgqqfKF');

		$this->assertSame(true, $this->csrfTokenManager->isTokenValid($token));
	}
}