-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathIdDocsControllerTest.php
More file actions
89 lines (76 loc) · 1.95 KB
/
IdDocsControllerTest.php
File metadata and controls
89 lines (76 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
82
83
84
85
86
87
88
89
<?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 IdDocsControllerTest extends ApiTestCase {
/**
* @runInSeparateProcess
*/
public function testPostIdDocsWithInvalidData():void {
$this->createAccount('username', 'password');
$this->request
->withMethod('POST')
->withRequestHeader([
'Authorization' => 'Basic ' . base64_encode('username:password'),
'Content-Type' => 'application/json'
])
->withRequestBody([
'files' => [
[
'type' => 'INVALID',
'file' => [
'base64' => 'invalid'
]
]
]
])
->withPath('/api/v1/id-docs')
->assertResponseCode(401);
$this->assertRequest();
}
/**
* @runInSeparateProcess
*/
public function testPostIdDocsWithSuccess():void {
$this->createAccount('username', 'password');
$this->request
->withMethod('POST')
->withRequestHeader([
'Authorization' => 'Basic ' . base64_encode('username:password'),
'Content-Type' => 'application/json'
])
->withRequestBody([
'files' => [
[
'type' => 'IDENTIFICATION',
'file' => [
'base64' => base64_encode(file_get_contents(__DIR__ . '/../../fixtures/pdfs/small_valid.pdf'))
]
]
]
])
->withPath('/api/v1/id-docs');
$this->assertRequest();
}
/**
* @runInSeparateProcess
*/
public function testApprovalListWithSuccess():void {
$this->createAccount('allowapprove', 'password', 'testGroup');
$this->getMockAppConfig()->setValueArray(Application::APP_ID, 'approval_group', ['testGroup']);
$this->request
->withPath('/api/v1/id-docs/approval/list')
->withRequestHeader([
'Authorization' => 'Basic ' . base64_encode('allowapprove:password')
]);
$this->assertRequest();
}
}