-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for photo REST API, fix missing encryption
- Loading branch information
1 parent
2f4a959
commit e16d8b4
Showing
2 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...erver/src/test/java/com/wultra/security/userdatastore/restclient/PhotoRestClientTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* User Data Store | ||
* Copyright (C) 2024 Wultra s.r.o. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.wultra.security.userdatastore.restclient; | ||
|
||
import com.wultra.security.userdatastore.UserDataStoreRestClient; | ||
import com.wultra.security.userdatastore.UserDataStoreRestClientConfiguration; | ||
import com.wultra.security.userdatastore.client.model.request.AttachmentCreateRequest; | ||
import com.wultra.security.userdatastore.client.model.request.DocumentCreateRequest; | ||
import com.wultra.security.userdatastore.client.model.request.PhotoCreateRequest; | ||
import com.wultra.security.userdatastore.client.model.response.AttachmentCreateResponse; | ||
import com.wultra.security.userdatastore.client.model.response.DocumentCreateResponse; | ||
import com.wultra.security.userdatastore.client.model.response.PhotoCreateResponse; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.web.server.LocalServerPort; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
import java.util.Collections; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
/** | ||
* Attachment REST API test. | ||
* | ||
* @author Roman Strobl, [email protected] | ||
*/ | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@ActiveProfiles("test") | ||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
class PhotoRestClientTest { | ||
|
||
private static final String USER_DATA_STORE_REST_URL = "http://localhost:%d/user-data-store-server"; | ||
|
||
@LocalServerPort | ||
private int serverPort; | ||
|
||
private UserDataStoreRestClient restClient; | ||
|
||
@BeforeAll | ||
void initRestClient() throws Exception { | ||
UserDataStoreRestClientConfiguration config = new UserDataStoreRestClientConfiguration(); | ||
config.setHttpBasicUsername("admin"); | ||
config.setHttpBasicPassword("admin"); | ||
restClient = new UserDataStoreRestClient(USER_DATA_STORE_REST_URL.formatted(serverPort), config); | ||
} | ||
|
||
@Test | ||
void testPost() throws Exception { | ||
DocumentCreateRequest request = new DocumentCreateRequest("alice", "test", "test", "1", null, "test_data", Collections.emptyMap()); | ||
DocumentCreateResponse response = restClient.createDocument(request); | ||
assertNotNull(response.id()); | ||
assertNotNull(response.documentId()); | ||
PhotoCreateRequest photoRequest = new PhotoCreateRequest("alice", response.id(), "test", "test_data", null); | ||
PhotoCreateResponse photoResponse = restClient.createPhoto(photoRequest); | ||
assertNotNull(photoResponse.id()); | ||
assertNotNull(photoResponse.documentId()); | ||
} | ||
} |