summaryrefslogtreecommitdiffstats
path: root/tests/lib/share/share.php
blob: eca2c9bc58aab00a756e07bea684f44d1e2b1f1f (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
153
154
155
156
157
158
159
160
161
<?php
/**
* ownCloud
*
* @author Michael Gapczynski
* @copyright 2012 Michael Gapczynski mtgap@owncloud.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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 along with this library.  If not, see <http://www.gnu.org/licenses/>.
*/

class Test_Share_Base extends UnitTestCase {

	protected $itemType;
	protected $userBackend;
	protected $user1;
	protected $user2;
	protected $groupBackend;
	protected $group1;
	protected $group2;


	public function setUp() {
		OC_User::clearBackends();
		OC_User::useBackend('dummy');
		$this->user1 = uniqid('user_');
		$this->user2 = uniqid('user_');
		OC_User::createUser($this->user1, 'pass1');
		OC_User::createUser($this->user2, 'pass2');
		OC_Group::clearBackends();
		OC_Group::useBackend(new OC_Group_Dummy);
		$this->group1 = uniqid('group_');
		$this->group2 = uniqid('group_');
		OC_Group::createGroup($this->group1);
		OC_Group::createGroup($this->group2);
	}

	public function testShareInvalidShareType() {
		$this->assertFalse(OCP\Share::share('file', 'test.txt', 'foobar', $this->user1, OCP\Share::PERMISSION_READ));
	}

	public function testShareInvalidItemType() {
		$this->assertFalse(OCP\Share::share('foobar', 'test.txt', OCP\Share::SHARETYPE_USER, $this->user1, OCP\Share::PERMISSION_READ));
	}

	public function testShareWithSelf() {
		OC_User::setUserId($this->user1);
		$this->assertFalse(OCP\Share::share('file', 'test.txt', OCP\Share::SHARETYPE_USER, $this->user1, OCP\Share::PERMISSION_READ));
	}

	public function testShareWithNonExistentUser() {
		$this->assertFalse(OCP\Share::share('file', 'test.txt', OCP\Share::SHARETYPE_USER, 'foobar', OCP\Share::PERMISSION_READ));
	}

	public function testShareWithUserOwnerNotPartOfGroup() {
		
	}

	public function testShareWithUserAlreadySharedWith() {
		
	}

	public function testShareWithNonExistentGroup() {
		$this->assertFalse(OCP\Share::share('file', 'test.txt', OCP\Share::SHARETYPE_GROUP, 'foobar', OCP\Share::PERMISSION_READ));
	}

	public function testShareWithGroupOwnerNotPartOfGroup() {

	}


	public function testShareWithGroupItem() {

	}

	public function testUnshareInvalidShareType() {

	}

	public function testUnshareNonExistentItem() {

	}

	public function testUnshareFromUserItem() {

	}

	public function testUnshareFromGroupItem() {

	}

	


	
		// Test owner not in same group (false)

		

		// Test non-existant item type

		// Test valid item

		// Test existing shared item (false)
		
		// Test unsharing item

		// Test setting permissions

		// Test setting permissions not as owner (false)

		// Test setting target

		// Test setting target as owner (false)
		
		// Spam reshares

		

		// Test non-existant group
		

		// Test owner not part of group

		// Test existing shared item with group

		// Test valid item, valid name for all users

		// Test unsharing item

		// Test item with name conflicts

		// Test unsharing item

		// Test setting permissions

		// Test setting target no name conflicts

		// Test setting target with conflicts

		// Spam reshares

		

		

	public function testPrivateLink() {
		
	}

}