|
11 | 11 | namespace OCA\Mail\Tests\Unit\Controller; |
12 | 12 |
|
13 | 13 | use ChristophWurst\Nextcloud\Testing\TestCase; |
14 | | -use Exception; |
15 | 14 | use OCA\Mail\Controller\ProxyController; |
16 | 15 | use OCA\Mail\Html\ProxyHmacGenerator; |
17 | 16 | use OCA\Mail\Http\ProxyDownloadResponse; |
18 | 17 | use OCA\Mail\Service\MailManager; |
19 | 18 | use OCP\AppFramework\Db\DoesNotExistException; |
20 | 19 | use OCP\AppFramework\Http; |
21 | 20 | use OCP\AppFramework\Http\Response; |
22 | | -use OCP\AppFramework\Http\TemplateResponse; |
23 | 21 | use OCP\Http\Client\IClient; |
24 | 22 | use OCP\Http\Client\IClientService; |
25 | 23 | use OCP\Http\Client\IResponse; |
@@ -73,98 +71,6 @@ protected function setUp(): void { |
73 | 71 | $this->logger = new NullLogger(); |
74 | 72 | } |
75 | 73 |
|
76 | | - public function redirectDataProvider() { |
77 | | - return [ |
78 | | - [ |
79 | | - 'http://nextcloud.com', |
80 | | - false, |
81 | | - false |
82 | | - ], |
83 | | - [ |
84 | | - 'https://nextcloud.com', |
85 | | - false, |
86 | | - false |
87 | | - ], |
88 | | - [ |
89 | | - 'http://nextcloud.com', |
90 | | - true, |
91 | | - true |
92 | | - ], |
93 | | - [ |
94 | | - 'http://example.com', |
95 | | - false, |
96 | | - false |
97 | | - ], |
98 | | - [ |
99 | | - 'https://example.com', |
100 | | - true, |
101 | | - true |
102 | | - ], |
103 | | - [ |
104 | | - 'ftp://example.com', |
105 | | - true, |
106 | | - true |
107 | | - ], |
108 | | - ]; |
109 | | - } |
110 | | - |
111 | | - /** |
112 | | - * @dataProvider redirectDataProvider |
113 | | - */ |
114 | | - public function testRedirect(string $url, |
115 | | - bool $passesTest, |
116 | | - bool $authorized) { |
117 | | - $this->urlGenerator->expects($this->once()) |
118 | | - ->method('linkToRoute') |
119 | | - ->with('mail.page.index') |
120 | | - ->will($this->returnValue('mail-route')); |
121 | | - $this->request->expects($this->once()) |
122 | | - ->method('passesStrictCookieCheck') |
123 | | - ->willReturn($passesTest); |
124 | | - $this->controller = new ProxyController( |
125 | | - $this->appName, |
126 | | - $this->request, |
127 | | - $this->urlGenerator, |
128 | | - $this->session, |
129 | | - $this->clientService, |
130 | | - $this->hmacGenerator, |
131 | | - $this->logger, |
132 | | - $this->mailManager, |
133 | | - $this->userId, |
134 | | - ); |
135 | | - $expected = new TemplateResponse( |
136 | | - $this->appName, |
137 | | - 'redirect', |
138 | | - [ |
139 | | - 'authorizedRedirect' => $authorized, |
140 | | - 'url' => $url, |
141 | | - 'urlHost' => parse_url($url, PHP_URL_HOST), |
142 | | - 'mailURL' => 'mail-route' |
143 | | - ], |
144 | | - 'guest' |
145 | | - ); |
146 | | - |
147 | | - $response = $this->controller->redirect($url); |
148 | | - |
149 | | - $this->assertEquals($expected, $response); |
150 | | - } |
151 | | - |
152 | | - public function testRedirectInvalidUrl() { |
153 | | - $this->controller = new ProxyController( |
154 | | - $this->appName, |
155 | | - $this->request, |
156 | | - $this->urlGenerator, |
157 | | - $this->session, |
158 | | - $this->clientService, |
159 | | - $this->hmacGenerator, |
160 | | - $this->logger, |
161 | | - $this->mailManager, |
162 | | - $this->userId, |
163 | | - ); |
164 | | - $this->expectException(Exception::class); |
165 | | - |
166 | | - $this->controller->redirect('ftps://example.com'); |
167 | | - } |
168 | 74 |
|
169 | 75 | public function testProxyWithoutCookies(): void { |
170 | 76 | $src = 'http://example.com'; |
|
0 commit comments