--- title: Overview order: 1 layout: page --- [[components.overview]] = Overview Vaadin provides a comprehensive set of user interface components and allows you to define custom components. <> illustrates the inheritance hierarchy of the UI component classes and interfaces. Interfaces are displayed in gray, abstract classes in orange, and regular classes in blue. An annotated version of the diagram is featured in the __Vaadin Cheat Sheet__. [[figure.uicomponents]] .User Interface Component Class Hierarchy image::img/component-diagram-hi.png[width=100%, scaledwidth=100%] ((("[classname]#Component#"))) At the top of the interface hierarchy, we have the [classname]#Component# interface. ((("[classname]#AbstractComponent#"))) At the top of the class hierarchy, we have the [classname]#AbstractComponent# class. ((("[classname]#AbstractField#"))) ((("[classname]#AbstractComponentContainer#"))) It is inherited by two other abstract classes: [classname]#AbstractField#, inherited further by field components, and [classname]#AbstractComponentContainer#, inherited by various container and layout components. Components that are not bound to a content data model, such as labels and links, inherit [classname]#AbstractComponent# directly. ((("layout"))) ((("[classname]#Layout#"))) The layout of the various components in a window is controlled, logically, by layout components, just like in conventional Java UI toolkits for desktop applications. In addition, with the [classname]#CustomLayout# component, you can write a custom layout as an HTML template that includes the locations of any contained components. Looking at the inheritance diagram, we can see that layout components inherit the [classname]#AbstractComponentContainer# and the [classname]#Layout# interface. Layout components are described in detail in <>. ((("[classname]#Window#"))) Looking at it from the perspective of an object hierarchy, we would have a [classname]#Window# object, which contains a hierachy of layout components, which again contain other layout components, field components, and other visible components. ((("Sampler"))) ((("JavaDoc"))) You can browse the built-in UI components of Vaadin library in the Sampler application of the Vaadin Demo. The Sampler shows a description, JavaDoc documentation, and a code samples for each of the components. In addition to the built-in components, many components are available as add-ons, either from the Vaadin Directory or from independent sources. Both commercial and free components exist. The installation of add-ons is described in <>. [NOTE] .Vaadin Cheat Sheet and Refcard ==== <> is included in the Vaadin Cheat Sheet that illustrates the basic relationship hierarchy of the user interface components and data binding classes and interfaces. You can download it at http://vaadin.com/book. The diagram is also included in the six-page DZone Refcard, which you can find at https://vaadin.com/refcard. ==== d-integration-tests-for-renaming-a-share-by-a-user-with-stale-shares Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
blob: bd7e26d5e8f5ecead64032c51f055e408edf14ad (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
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
<?php

/**
 * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace OC\Core\Controller;

use OC\CapabilitiesManager;
use OC\Security\IdentityProof\Key;
use OC\Security\IdentityProof\Manager;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Server;
use OCP\ServerVersion;
use Test\TestCase;

class OCSControllerTest extends TestCase {
	/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
	private $request;
	/** @var CapabilitiesManager|\PHPUnit\Framework\MockObject\MockObject */
	private $capabilitiesManager;
	/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
	private $userSession;
	/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
	private $userManager;
	/** @var Manager|\PHPUnit\Framework\MockObject\MockObject */
	private $keyManager;
	/** @var ServerVersion|\PHPUnit\Framework\MockObject\MockObject */
	private $serverVersion;
	/** @var OCSController */
	private $controller;

	protected function setUp(): void {
		parent::setUp();

		$this->request = $this->createMock(IRequest::class);
		$this->capabilitiesManager = $this->createMock(CapabilitiesManager::class);
		$this->userSession = $this->createMock(IUserSession::class);
		$this->userManager = $this->createMock(IUserManager::class);
		$this->keyManager = $this->createMock(Manager::class);
		$serverVersion = Server::get(ServerVersion::class);

		$this->controller = new OCSController(
			'core',
			$this->request,
			$this->capabilitiesManager,
			$this->userSession,
			$this->userManager,
			$this->keyManager,
			$serverVersion
		);
	}

	public function testGetConfig() {
		$this->request->method('getServerHost')
			->willReturn('awesomehost.io');

		$data = [
			'version' => '1.7',
			'website' => 'Nextcloud',
			'host' => 'awesomehost.io',
			'contact' => '',
			'ssl' => 'false',
		];

		$expected = new DataResponse($data);
		$this->assertEquals($expected, $this->controller->getConfig());

		return new DataResponse($data);
	}

	public function testGetCapabilities(): void {
		$this->userSession->expects($this->once())
			->method('isLoggedIn')
			->willReturn(true);

		$serverVersion = Server::get(ServerVersion::class);

		$result = [];
		$result['version'] = [
			'major' => $serverVersion->getMajorVersion(),
			'minor' => $serverVersion->getMinorVersion(),
			'micro' => $serverVersion->getPatchVersion(),
			'string' => $serverVersion->getVersionString(),
			'edition' => '',
			'extendedSupport' => false
		];

		$capabilities = [
			'foo' => 'bar',
			'a' => [
				'b' => true,
				'c' => 11,
			]
		];
		$this->capabilitiesManager->method('getCapabilities')
			->willReturn($capabilities);

		$result['capabilities'] = $capabilities;

		$expected = new DataResponse($result);
		$expected->setETag(md5(json_encode($result)));
		$this->assertEquals($expected, $this->controller->getCapabilities());
	}

	public function testGetCapabilitiesPublic(): void {
		$this->userSession->expects($this->once())
			->method('isLoggedIn')
			->willReturn(false);
		$serverVersion = Server::get(ServerVersion::class);

		$result = [];
		$result['version'] = [
			'major' => $serverVersion->getMajorVersion(),
			'minor' => $serverVersion->getMinorVersion(),
			'micro' => $serverVersion->getPatchVersion(),
			'string' => $serverVersion->getVersionString(),
			'edition' => '',
			'extendedSupport' => false
		];

		$capabilities = [
			'foo' => 'bar',
			'a' => [
				'b' => true,
				'c' => 11,
			]
		];
		$this->capabilitiesManager->method('getCapabilities')
			->with(true)
			->willReturn($capabilities);

		$result['capabilities'] = $capabilities;

		$expected = new DataResponse($result);
		$expected->setETag(md5(json_encode($result)));
		$this->assertEquals($expected, $this->controller->getCapabilities());
	}

	public function testPersonCheckValid(): void {
		$this->userManager->method('checkPassword')
			->with(
				$this->equalTo('user'),
				$this->equalTo('pass')
			)->willReturn($this->createMock(IUser::class));

		$expected = new DataResponse([
			'person' => [
				'personid' => 'user'
			]
		]);
		$this->assertEquals($expected, $this->controller->personCheck('user', 'pass'));
	}

	public function testPersonInvalid(): void {
		$this->userManager->method('checkPassword')
			->with(
				$this->equalTo('user'),
				$this->equalTo('wrongpass')
			)->willReturn(false);

		$expected = new DataResponse([], 102);
		$expected->throttle();
		$this->assertEquals($expected, $this->controller->personCheck('user', 'wrongpass'));
	}

	public function testPersonNoLogin(): void {
		$this->userManager->method('checkPassword')
			->with(
				$this->equalTo('user'),
				$this->equalTo('wrongpass')
			)->willReturn(false);

		$expected = new DataResponse([], 101);
		$this->assertEquals($expected, $this->controller->personCheck('', ''));
	}

	public function testGetIdentityProofWithNotExistingUser(): void {
		$this->userManager
			->expects($this->once())
			->method('get')
			->with('NotExistingUser')
			->willReturn(null);

		$expected = new DataResponse(['Account not found'], 404);
		$this->assertEquals($expected, $this->controller->getIdentityProof('NotExistingUser'));
	}

	public function testGetIdentityProof(): void {
		$user = $this->createMock(IUser::class);
		$key = $this->createMock(Key::class);
		$this->userManager
			->expects($this->once())
			->method('get')
			->with('ExistingUser')
			->willReturn($user);
		$this->keyManager
			->expects($this->once())
			->method('getKey')
			->with($user)
			->willReturn($key);
		$key
			->expects($this->once())
			->method('getPublic')
			->willReturn('Existing Users public key');

		$expected = new DataResponse([
			'public' => 'Existing Users public key',
		]);
		$this->assertEquals($expected, $this->controller->getIdentityProof('ExistingUser'));
	}
}