This file is indexed.

/usr/share/php/tests/Horde_Kolab_Storage/Horde/Kolab/Storage/Unit/Folder/NamespaceTest.php is in php-horde-kolab-storage 2.0.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<?php
/**
 * Test the handling of namespaces.
 *
 * PHP version 5
 *
 * @category Kolab
 * @package  Kolab_Storage
 * @subpackage UnitTests
 * @author   Gunnar Wrobel <wrobel@pardus.de>
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @link     http://pear.horde.org/index.php?package=Kolab_Storage
 */

/**
 * Test the handling of namespaces.
 *
 * Copyright 2010-2013 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 *
 * @category Kolab
 * @package  Kolab_Storage
 * @author   Gunnar Wrobel <wrobel@pardus.de>
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @link     http://pear.horde.org/index.php?package=Kolab_Storage
 */
class Horde_Kolab_Storage_Unit_Folder_NamespaceTest
extends Horde_Kolab_Storage_TestCase
{
    public function setUp()
    {
        parent::setUp();
        $this->_storage = $this->getMock('Horde_Kolab_Storage', array(), array(), '', false, false);
        $this->_connection = $this->getMock('Horde_Kolab_Storage_Driver');
    }

    public function testTitleForPersonalNS()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('INBOX', $namespace);
            $this->assertEquals('', $folder->getTitle());
        }
    }

    public function testTitleWithoutPersonalPrefix()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('INBOX/test', $namespace);
            $this->assertEquals('test', $folder->getTitle());
        }
    }

    public function testTitleWithoutOtherUserPrefix()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('user/test/his_folder', $namespace);
            $this->assertEquals('his_folder', $folder->getTitle());
        }
    }

    public function testTitleSeparator()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('INBOX/test/sub', $namespace);
            $this->assertEquals('sub', $folder->getTitle());
        }
    }

    public function testOwnerForPersonalNS()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('INBOX', $namespace);
            $this->assertEquals('test', $folder->getOwner());
        }
    }

    public function testOwnerInPersonalNS()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('INBOX/mine', $namespace);
            $this->assertEquals('test', $folder->getOwner());
        }
    }

    public function testOwnerForOtherUserNS()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('user/test', $namespace);
            $this->assertEquals('test', $folder->getOwner());
        }
    }

    public function testOwnerInOtherUserNS()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('user/test/mine', $namespace);
            $this->assertEquals('test', $folder->getOwner());
        }
    }

    public function testAnonymousForSharedNamespace()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('shared.test', $namespace);
            $this->assertFalse($folder->getOwner());
        }
    }

    public function testOwnerDomain()
    {
        foreach ($this->_getNamespaces('test@example.com') as $namespace) {
            $folder = $this->_getFolder('user/test/mine', $namespace);
            $this->assertEquals('test@example.com', $folder->getOwner());
        }
    }

    public function testOwnerCurrentDomain()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('user/test/mine@example.com', $namespace);
            $this->assertEquals('test@example.com', $folder->getOwner());
        }
    }

    public function testSubpathWithoutUsername()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('user/test/mine', $namespace);
            $this->assertEquals('mine', $folder->getSubpath());
        }
    }

    public function testSubpathWithoutPrefix()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('INBOX/a/b', $namespace);
            $this->assertEquals('a/b', $folder->getSubpath());
        }
    }

    public function testParent()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('INBOX/a/b', $namespace);
            $this->assertEquals('INBOX/a', $folder->getParent());
        }
    }

    public function testRoot()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('INBOX/a', $namespace);
            $this->assertEquals('INBOX', $folder->getParent());
        }
    }

    public function testParentInOther()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('user/test/mine/a', $namespace);
            $this->assertEquals('user/test/mine', $folder->getParent());
        }
    }

    public function testRootInOther()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('user/test/mine', $namespace);
            $this->assertEquals('user/test', $folder->getParent());
        }
    }

    public function testParentInShared()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('shared.a/b', $namespace);
            $this->assertEquals('shared.a', $folder->getParent());
        }
    }

    public function testRootInShared()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('shared.a', $namespace);
            $this->assertEquals('', $folder->getParent());
        }
    }

    public function testSubpathWithoutSharedPrefix()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $folder = $this->_getFolder('shared.a/b', $namespace);
            $this->assertEquals('a/b', $folder->getSubpath());
        }
    }

    public function testConstructFolderNamePersonal()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $this->assertEquals('INBOX/b', $namespace->constructFolderName('test', 'b'));
        }
    }

    public function testConstructFolderNameOther()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $this->assertEquals('user/other/c', $namespace->constructFolderName('other', 'c'));
        }
    }

    public function testConstructFolderNameShared()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $this->assertEquals('shared.c', $namespace->constructFolderName(null, 'c'));
        }
    }

    public function testConstructFolderPathPersonal()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $this->assertEquals('INBOX/b', $namespace->constructFolderName('test', 'b', 'INBOX'));
        }
    }

    public function testConstructFolderPathOther()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $this->assertEquals('user/other/c', $namespace->constructFolderName('other', 'c', 'user'));
        }
    }

    public function testConstructFolderPathOtherWithDomain()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $this->assertEquals('user/other/c@domain.de', $namespace->constructFolderName('other@domain.de', 'c', 'user'));
        }
    }

    public function testConstructFolderPathOtherWithoutDomain()
    {
        foreach ($this->_getNamespaces('test@domain.de') as $namespace) {
            $this->assertEquals('user/other/c', $namespace->constructFolderName('other@domain.de', 'c', 'user'));
        }
    }

    public function testConstructFolderPathShared()
    {
        foreach ($this->_getNamespaces() as $namespace) {
            $this->assertEquals('shared.c', $namespace->constructFolderName(false, 'c', ''));
        }
    }

    public function testToString()
    {
        $namespace = new Horde_Kolab_Storage_Folder_Namespace_Fixed('test@example.com');
        $this->assertEquals(
            'Horde_Kolab_Storage_Folder_Namespace_Fixed: "INBOX" (personal, "/"), "user" (other, "/"), "" (shared, "/")',
            (string) $namespace
        );
    }

    public function testSerializable()
    {
        $data = array();
        foreach ($this->_getNamespaces() as $namespace) {
            $data[] = (string) unserialize(serialize($namespace));
        }
        $this->assertEquals(
            array(
                'Horde_Kolab_Storage_Folder_Namespace_Fixed: "INBOX" (personal, "/"), "user" (other, "/"), "" (shared, "/")',
                'Horde_Kolab_Storage_Folder_Namespace_Config: "INBOX" (personal, "/"), "user" (other, "/"), "" (shared, "/")',
                'Horde_Kolab_Storage_Folder_Namespace_Imap: "INBOX" (personal, "/"), "user" (other, "/"), "" (shared, "/")'
            ),
            $data
        );
    }

    private function _getFolder($name, $namespace)
    {
        $factory = new Horde_Kolab_Storage_Factory();
        $this->_connection->expects($this->any())
            ->method('getNamespace')
            ->will($this->returnValue($namespace));
        $this->_connection->expects($this->any())
            ->method('listFolders')
            ->will($this->returnValue(array($name)));
        $this->_connection->expects($this->any())
            ->method('listAnnotation')
            ->will($this->returnValue(array($name => 'mail')));
        $list = new Horde_Kolab_Storage_List_Query_List_Base(
            $this->_connection,
            new Horde_Kolab_Storage_Folder_Types(),
            new Horde_Kolab_Storage_List_Query_List_Defaults_Bail()
        );
        return new Horde_Kolab_Storage_Folder_Base($list, $name);
    }

    private function _getNamespaces($user = 'test')
    {
        return array(
            new Horde_Kolab_Storage_Folder_Namespace_Fixed($user),
            new Horde_Kolab_Storage_Folder_Namespace_Config(
                $user,
                array(
                    array(
                        'type' => Horde_Kolab_Storage_Folder_Namespace::PERSONAL,
                        'name' => 'INBOX/',
                        'delimiter' => '/',
                        'add' => true,
                    ),
                    array(
                        'type' => Horde_Kolab_Storage_Folder_Namespace::OTHER,
                        'name' => 'user/',
                        'delimiter' => '/',
                    ),
                    array(
                        'type' => Horde_Kolab_Storage_Folder_Namespace::SHARED,
                        'name' => '',
                        'delimiter' => '/',
                        'prefix' => 'shared.'
                    ),
                )
            ),
            new Horde_Kolab_Storage_Folder_Namespace_Imap(
                $user,
                array(
                    array(
                        'name'      => 'INBOX/',
                        'type'      =>  Horde_Kolab_Storage_Folder_Namespace::PERSONAL,
                        'delimiter' => '/',
                    ),
                    array(
                        'name'      => 'user/',
                        'type'      =>  Horde_Kolab_Storage_Folder_Namespace::OTHER,
                        'delimiter' => '/',
                    ),
                    array(
                        'name'      => '',
                        'type'      =>  Horde_Kolab_Storage_Folder_Namespace::SHARED,
                        'delimiter' => '/',
                        'prefix' => 'shared.'
                    ),
                )
            )
        );
    }
}