-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathNotifyControllerTest.php
More file actions
81 lines (74 loc) · 1.95 KB
/
NotifyControllerTest.php
File metadata and controls
81 lines (74 loc) · 1.95 KB
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
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Libresign\Tests\Api\Controller;
use OCA\Libresign\AppInfo\Application;
use OCA\Libresign\Tests\Api\ApiTestCase;
/**
* @group DB
*/
final class NotifyControllerTest extends ApiTestCase {
/**
* @runInSeparateProcess
*/
public function testNotifySignersWithError():void {
$this->createAccount('username', 'password');
$this->request
->withMethod('POST')
->withRequestHeader([
'Authorization' => 'Basic ' . base64_encode('username:password'),
'Content-Type' => 'application/json'
])
->withRequestBody([
'fileId' => 171,
'signers' => [
[
'email' => '[email protected]'
]
]
])
->withPath('/api/v1/notify/signers')
->assertResponseCode(401);
$this->assertRequest();
}
/**
* @runInSeparateProcess
*/
public function testNotifySignersWithSuccess():void {
$user = $this->createAccount('allowrequestsign', 'password', 'testGroup');
$appConfig = $this->getMockAppConfig();
$appConfig->setValueArray(Application::APP_ID, 'groups_request_sign', ['admin','testGroup']);
$appConfig->setValueBool(Application::APP_ID, 'notifyUnsignedUser', true);
$file = $this->requestSignFile([
'file' => ['base64' => base64_encode(file_get_contents(__DIR__ . '/../../fixtures/pdfs/small_valid.pdf'))],
'name' => 'test',
'users' => [
[
'identify' => [
'email' => '[email protected]',
],
],
],
'userManager' => $user,
]);
$this->request
->withMethod('POST')
->withRequestHeader([
'Authorization' => 'Basic ' . base64_encode('allowrequestsign:password'),
'Content-Type' => 'application/json'
])
->withRequestBody([
'fileId' => $file->getNodeId(),
'signers' => [
[
'email' => '[email protected]'
]
]
])
->withPath('/api/v1/notify/signers');
$this->assertRequest();
}
}