Commit a2c31ec0 authored by Rostyslav Matushkin (SLB)'s avatar Rostyslav Matushkin (SLB) Committed by Jason
Browse files

Actualization of how to run integration tests locally

parent 4b4238b7
......@@ -3,6 +3,7 @@
entitlements-v2-azure is a [Spring Boot](https://spring.io/projects/spring-boot) service which hosts CRUD APIs that enable management of user entitlements.
Data kept in Azure cosmos graph database.
### Graph structure
`id` - auto-generated property <br/>
......@@ -63,6 +64,7 @@ Parent edge:
"outV": "***"
}
### Requirements
In order to run this service locally, you will need the following:
......@@ -72,6 +74,7 @@ In order to run this service locally, you will need the following:
- Infrastructure dependencies, deployable through the relevant [infrastructure template](https://dev.azure.com/slb-des-ext-collaboration/open-data-ecosystem/_git/infrastructure-templates?path=%2Finfra&version=GBmaster&_a=contents)
- While not a strict dependency, example commands in this document use [bash](https://www.gnu.org/software/bash/)
### General Tips
**Environment Variable Management**
......@@ -84,9 +87,10 @@ This project uses [Lombok](https://projectlombok.org/) for code generation. You
- [Intellij configuration](https://projectlombok.org/setup/intellij)
- [VSCode configuration](https://projectlombok.org/setup/vscode)
### Environment Variables
In order to run the service locally, you will need to have the following environment variables defined.
In order to run the service locally, you will need to have defined environment variables that you can find [here](https://community.opengroup.org/osdu/platform/deployment-and-operations/infra-azure-provisioning/-/blob/master/tools/variables/entitlements.sh#L150).
**Note** The following command can be useful to pull secrets from keyvault:
```bash
......@@ -100,23 +104,6 @@ az keyvault secret show --vault-name $KEY_VAULT_NAME --name $KEY_VAULT_SECRET_NA
In Order to run service with Istio authentication, add below environment variables. This is needed only to test Istio filter scenarios,
with these settings service expects "x-payload" header which contains Base64 encoded format of Payload. In this approach service will not do Authentication.
name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `azure_istioauth_enabled` | `true` | Flag to Disable AAD auth | no | -- |
| `service_domain_name` | ex `contoso.com` | The name of the domain for which the service will run | no | output of infrastructure deployment |
**Required to run integration tests**
| name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `ENTITLEMENT_V2_URL` | ex `http://localhost:8080/api/entitlements/v2` | The host where the service is running | no | -- |
| `DOMAIN` | ex `contoso.com` | The domain of the environment | no | -- |
| `INTEGRATION_TESTER` | `********` | System identity to assume for API calls. Note: this user must have entitlements configured already | no | -- |
| `AZURE_TESTER_SERVICEPRINCIPAL_SECRET` | `********` | Secret for `$INTEGRATION_TESTER` | yes | -- |
| `AZURE_AD_TENANT_ID` | `********` | AD tenant to authenticate users from | yes | -- |
| `AZURE_AD_APP_RESOURCE_ID` | `********` | AAD client application ID | yes | output of infrastructure deployment |
| `NO_DATA_ACCESS_TESTER` | `********` | Service principal ID of a service principal without entitlements | yes | `osdu-infra-test-app-noaccess-id` secret from keyvault |
| `NO_DATA_ACCESS_TESTER_SERVICEPRINCIPAL_SECRET` | `********` | Secret for `$NO_DATA_ACCESS_TESTER` | yes | `osdu-infra-test-app-noaccess-key` secret from keyvault |
### Build and run the application
......@@ -136,26 +123,83 @@ $ java -jar $(find provider/entitlements-v2-azure/target/ -name '*-spring-boot.j
$ ./mvnw spring-boot:run -pl provider/entitlements-v2-azure
```
### Test the application
How to setup local environment, including cosmos db, please refer to: testing/entitlements-v2-test-azure/README.md
How to run the integration tests:
#### Using Cloud Infrastructure
1. Run Entitlements V2 service from Azure provider (assumed that all the required environment variables are specified for using Cloud Infrastructure).
2. Define environment variables for integration tests (e.g. maven options):
| Name | Value | Description | Sensitive? | Source |
| -------------------------------------- | ---------------------------------------------- | -------------------------------------------------------------------------------------------------- | ---------- | ----------------------------------- |
| `ENTITLEMENT_V2_URL` | ex `http://localhost:8080/api/entitlements/v2` | The host where the service is running | no | -- |
| `DOMAIN` | ex `contoso.com` | The domain of the environment | no | -- |
| `INTEGRATION_TESTER` | `********` | System identity to assume for API calls. Note: this user must have entitlements configured already | no | -- |
| `AZURE_TESTER_SERVICEPRINCIPAL_SECRET` | `********` | Secret for `INTEGRATION_TESTER` | yes | -- |
| `AZURE_AD_TENANT_ID` | `********` | AD tenant to authenticate users from | yes | -- |
| `AZURE_AD_APP_RESOURCE_ID` | `********` | AAD client application ID | yes | output of infrastructure deployment |
3. Run integration tests:
```bash
# build + install integration test core
$ ./mvnw compile -f testing/entitlements-v2-test-core
# build + run Azure integration tests.
$ ./mvnw test -f testing/entitlements-v2-test-azure
```
#### Using CosmosDB Emulator
1. Set up CosmosDB Emulator
- Download [Azure Cosmos emulator](https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator?tabs=cli%2Cssl-netstd21#download-the-emulator) and save the program to your desktop
- Navigate to the directory and start the emulator from command prompt. This should pop up the Emulator in localhost:8081
```
Microsoft.Azure.Cosmos.Emulator.exe /EnableGremlinEndpoint
```
- Go to Explorer tab and create a database `osdu-graph` and a collection `Entitlements`. For the partition key, use `/dataPartitionId`
2. Using this tool [Entitlements data uploader](https://community.opengroup.org/osdu/platform/deployment-and-operations/infra-azure-provisioning/-/tree/master/tools/test_data/entitlements_data_uploader), populate CosmosDB Emulator by required data for integration tests.
3. Temporarily hardcode in `provider/entitlements-v2-azure/src/main/resources/application.properties` the following properties:
- `app.gremlin.port`=`8901`
- `app.gremlin.sslEnabled`=`false`
4. Temporarily hardcode in `provider/entitlements-v2-azure/src/main/java/org/opengroup/osdu/entitlements/v2/azure/AzureAppProperties.java` the following methods so that they start returning such values:
- `getGraphDbEndpoint()`=`localhost`
- `getGraphDbPassword()`=`C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==`
5. Run Entitlements V2 service from Azure provider.
6. Define environment variables for integration tests (e.g. maven options):
| Name | Value | Description | Sensitive? | Source |
| -------------------------------------- | ---------------------------------------------- | -------------------------------------------------------------------------------------------------- | ---------- | ----------------------------------- |
| `ENTITLEMENT_V2_URL` | ex `http://localhost:8080/api/entitlements/v2` | The host where the service is running | no | -- |
| `DOMAIN` | ex `contoso.com` | The domain of the environment | no | -- |
| `INTEGRATION_TESTER` | `********` | System identity to assume for API calls. Note: this user must have entitlements configured already | no | -- |
| `AZURE_TESTER_SERVICEPRINCIPAL_SECRET` | `********` | Secret for `INTEGRATION_TESTER` | yes | -- |
| `AZURE_AD_TENANT_ID` | `********` | AD tenant to authenticate users from | yes | -- |
| `AZURE_AD_APP_RESOURCE_ID` | `********` | AAD client application ID | yes | output of infrastructure deployment |
7. Run integration tests:
```bash
# build + install integration test core
$ ./mvnw compile -f testing/entitlements-v2-test-core
# build + run Azure integration tests.
#
# Note: this assumes that the environment variables for integration tests as outlined
# above are already exported in your environment.
$ ./mvnw test -f testing/entitlements-v2-test-azure
```
## Debugging
Jet Brains - the authors of Intellij IDEA, have written an [excellent guide](https://www.jetbrains.com/help/idea/debugging-your-first-java-application.html) on how to debug java programs.
## Deploying the Service
Service deployments into Azure are standardized to make the process the same for all services if using ADO and are
......@@ -163,6 +207,7 @@ closely related to the infrastructure deployed. The steps to deploy into Azure c
The default ADO pipeline is /devops/pipeline.yml
## License
Copyright © Microsoft Corporation
......@@ -177,3 +222,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
......@@ -27,11 +27,37 @@
<artifactId>entitlements-v2-core</artifactId>
<version>${project.version}</version>
</dependency>
<!--
Old versions of 'com.nimbusds:oauth2-oidc-sdk' and 'com.microsoft.azure:msal4j' are excluded
because they cannot work with Spring Boot version 2.4.x
New version of 'com.microsoft.azure:msal4j' is added to work with Spring Boot version 2.4.x
Stay tuned for a new version of 'com.azure:azure-identity', they started releasing updates, but it's still in beta.
More details here: https://github.com/Azure/azure-sdk-for-java
-->
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<version>${core-lib-azure.version}</version>
<exclusions>
<exclusion>
<groupId>com.nimbusds</groupId>
<artifactId>oauth2-oidc-sdk</artifactId>
</exclusion>
<exclusion>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
......
......@@ -35,11 +35,8 @@ tenantInfo.container.name=TenantInfo
azure.cosmosdb.database=${cosmosdb_database:}
# Graph db configuration
# In case local cosmos db emulator is used, please set as '8901'
app.graph.db.port=443
# In case local cosmos db emulator is used, please set as '/dbs/db1/colls/coll1'
app.graph.db.username=/dbs/osdu-graph/colls/Entitlements
# In case local cosmos db emulator is used, please set as 'false'
app.graph.db.sslEnabled=true
# App configuration
......
### How To Run Azure Integration Tests in local environment
1. Temporarily hardcode `requestInfo.getTenantInfo().getServiceAccount()` with datafier account id in following classes:
- ListGroupService
- DeleteGroupService
- RemoveMemberService
- KeySvcAccBeanConfiguration
- PermissionService
2. Set Up CosmosDB Emulator
- Download [Azure Cosmos emulator](https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator?tabs=cli%2Cssl-netstd21#download-the-emulator) and save the program to your desktop.
- Navigate to the directory and start the emulator from command prompt. This should pop up the Emulator in localhost:8081.
```
Microsoft.Azure.Cosmos.Emulator.exe /EnableGremlinEndpoint
```
- Go to 'Explorer' tab and create a database "db1" and a collection "coll1". For the partition key, use "/dataPartitionId".
3. Set Up Gremlin Console
- Download [apache-tinkerpop-gremlin-console-3.3.4](https://archive.apache.org/dist/tinkerpop/3.3.4/)
- Place `testing/entitlements-v2-test-azure/src/test/resources/local/remote-localcompute.yaml` in conf folder of
apache-tinkerpop-gremlin-console
4. Add Bootstrap Data to CosmosDB Emulator using Gremlin Console
- Run `bin\gremlin.bat` from apache-tinkerpop-gremlin-console-3.3.4 directory to start Gremlin Console.
- Once console has started, run these commands to connect to Emulator:
```
:remote connect tinkerpop.server conf/remote-localcompute.yaml
:remote console
```
- Run gremlin queries from `testing/entitlements-v2-test-azure/src/test/resources/bootstrap/bootstrap-data-local.txt`
5. Temporarily hardcode in provider/entitlements-v2-azure/src/main/resources/application.properties the following properties:
app.gremlin.sslEnabled to 'false'
app.gremlin.port to '8901'
6. Run Entitlements V2 service from Azure provider
7. Define 5 env variables for integration tests (e.g. maven options):
1. ENTITLEMENT_V2_URL=`http://localhost:8080/api/entitlements/v2`
2. INTEGRATION_TESTER=`Keyvault > Choose 'app-dev-sp-username' -> Copy Secret value`
3. AZURE_TESTER_SERVICEPRINCIPAL_SECRET=`Keyvault > Choose 'app-dev-sp-password' -> Copy Secret value`
4. AZURE_AD_TENANT_ID=`Keyvault > Choose 'app-dev-sp-tenant-id' -> Copy Secret value`
5. AZURE_AD_APP_RESOURCE_ID=`Keyvault > Choose 'aad-client-id' -> Copy Secret value`
8. Run integration tests
......@@ -15,13 +15,7 @@ public class AzureTokenService implements TokenService {
System.getProperty("AZURE_AD_TENANT_ID", System.getenv("AZURE_AD_TENANT_ID"));
private static final String APP_RESOURCE_ID =
System.getProperty("AZURE_AD_APP_RESOURCE_ID", System.getenv("AZURE_AD_APP_RESOURCE_ID"));
private static final String NO_DATA_ACCESS_CLIENT_ID =
System.getProperty("NO_DATA_ACCESS_TESTER", System.getenv("NO_DATA_ACCESS_TESTER"));
private static final String NO_DATA_ACCESS_CLIENT_SECRET =
System.getProperty("NO_DATA_ACCESS_TESTER_SERVICEPRINCIPAL_SECRET",
System.getenv("NO_DATA_ACCESS_TESTER_SERVICEPRINCIPAL_SECRET"));
private static String TOKEN;
private static String NODATAACEESSTOKEN;
/**
* Returns token of a service principal
......@@ -29,7 +23,7 @@ public class AzureTokenService implements TokenService {
@Override
public synchronized Token getToken() {
if (Strings.isNullOrEmpty(TOKEN)) {
TOKEN = retrieveToken(CLIENT_ID, CLIENT_SECRET);
TOKEN = retrieveToken();
}
return Token.builder()
.value(TOKEN)
......@@ -37,19 +31,9 @@ public class AzureTokenService implements TokenService {
.build();
}
@Override
public synchronized Token getNoDataAccessToken() {
if (Strings.isNullOrEmpty(NODATAACEESSTOKEN)) {
NODATAACEESSTOKEN = retrieveToken(NO_DATA_ACCESS_CLIENT_ID, NO_DATA_ACCESS_CLIENT_SECRET);
}
return Token.builder()
.value(NODATAACEESSTOKEN)
.userId(NO_DATA_ACCESS_CLIENT_ID)
.build(); }
private String retrieveToken(String clientId, String clientSecret) {
private String retrieveToken() {
try {
return new AzureServicePrincipal().getIdToken(clientId, clientSecret, TENANT_ID, APP_RESOURCE_ID);
return new AzureServicePrincipal().getIdToken(CLIENT_ID, CLIENT_SECRET, TENANT_ID, APP_RESOURCE_ID);
} catch (Exception e) {
throw new RuntimeException("Cannot retrieve token", e);
}
......
TODO: please remove these instructions, when these changes will be migrated to
https://community.opengroup.org/osdu/platform/deployment-and-operations/infra-azure-provisioning/-/tree/master/tools/test_data
How to get id of integration tester:
UNIQUE - is the id of the environment, for example: "dev"
GROUP=$(az group list --query "[?contains(name, 'cr${UNIQUE}')].name" -otsv)
ENV_VAULT=$(az keyvault list --resource-group $GROUP --query [].name -otsv)
INT_TESTER_ID=$(az keyvault secret show --id https://${ENV_VAULT}.vault.azure.net/secrets/app-dev-sp-id --query value -otsv)
TODO: refactor this script to add all the groups needed for the environment in correct hierarchy.
Bootstrap data to run integration tests:
g.addV('GROUP').property('nodeId', 'users.data.root@opendes.contoso.com').property('name', 'users.data.root').property('description', '').property('dataPartitionId','opendes').property('appIds','[]')
g.addV('USER').property('nodeId', 'user1@desid.com').property('dataPartitionId', 'opendes')
g.V().has('nodeId','users.data.root@opendes.contoso.com').addE('child').property('role', 'OWNER').to(g.V().has('nodeId','user1@desid.com'))
g.addV('GROUP').property('nodeId', 'service.entitlements.user@opendes.contoso.com').property('name', 'service.entitlements.user').property('description', '').property('dataPartitionId','opendes').property('appIds','[]')
g.addV('GROUP').property('nodeId', 'service.entitlements.admin@opendes.contoso.com').property('name', 'service.entitlements.admin').property('description', '').property('dataPartitionId','opendes').property('appIds','[]')
g.addV('GROUP').property('nodeId', 'users.datalake.ops@opendes.contoso.com').property('name', 'users.datalake.ops').property('description', '').property('dataPartitionId','opendes').property('appIds','[]')
g.addV('GROUP').property('nodeId', 'users@opendes.contoso.com').property('name', 'users').property('description', '').property('dataPartitionId','opendes').property('appIds','[]')
g.addV('USER').property('nodeId', '$INT_TESTER_ID').property('dataPartitionId', 'opendes')
g.V().has('nodeId','service.entitlements.user@opendes.contoso.com').addE('child').property('role', 'OWNER').to(g.V().has('nodeId','$INT_TESTER_ID'))
g.V().has('nodeId','service.entitlements.admin@opendes.contoso.com').addE('child').property('role', 'OWNER').to(g.V().has('nodeId','$INT_TESTER_ID'))
g.V().has('nodeId','users.datalake.ops@opendes.contoso.com').addE('child').property('role', 'OWNER').to(g.V().has('nodeId','$INT_TESTER_ID'))
g.V().has('nodeId','users@opendes.contoso.com').addE('child').property('role', 'OWNER').to(g.V().has('nodeId','$INT_TESTER_ID'))
g.addV('USER').property('nodeId', 'testMember@test.com').property('dataPartitionId', 'opendes')
g.addV('USER').property('nodeId', 'testmMemberOwner@test.com').property('dataPartitionId', 'opendes')
hosts: [localhost]
port: 8901
username: /dbs/db1/colls/coll1
password: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
connectionPool: {enableSsl: false}
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { serializeResultToString: true }}
......@@ -25,8 +25,6 @@ public abstract class AcceptanceBaseTest {
this.currentTime = System.currentTimeMillis();
}
protected abstract RequestData getRequestDataForUnauthorizedTest();
protected abstract RequestData getRequestDataForNoTokenTest();
protected void cleanup() throws Exception {
......
......@@ -63,20 +63,6 @@ public abstract class AddMemberTest extends AcceptanceBaseTest {
// TODO add revoke member logic for memberEmail and ownerMemberEmail
}
@Override
protected RequestData getRequestDataForUnauthorizedTest() {
Token noAccessToken = tokenService.getNoDataAccessToken();
Map<String, String> requestBody = new HashMap<>();
requestBody.put("role", "MEMBER");
requestBody.put("email", "memberName-" + System.currentTimeMillis() + "@test.com");
return RequestData.builder()
.method("POST").dataPartitionId(configurationService.getTenantId())
.relativePath(String.format("groups/%s/members", configurationService.getIdOfGroup("users")))
.body(new Gson().toJson(requestBody))
.token(noAccessToken.getValue())
.build();
}
@Override
protected RequestData getRequestDataForNoTokenTest() {
Map<String, String> requestBody = new HashMap<>();
......
......@@ -64,18 +64,6 @@ public abstract class CreateGroupTest extends AcceptanceBaseTest {
Assert.assertEquals(expectedConflictResponse, new Gson().fromJson(conflictResponse.getEntity(String.class), ErrorResponse.class));
}
@Override
protected RequestData getRequestDataForUnauthorizedTest() {
Token noAccessToken = tokenService.getNoDataAccessToken();
return RequestData.builder()
.method("POST").dataPartitionId(configurationService.getTenantId())
.relativePath("groups")
.body(new Gson().toJson(GroupItem.builder().name("groupName-" + System.currentTimeMillis())
.description("desc").build()))
.token(noAccessToken.getValue())
.build();
}
@Override
protected RequestData getRequestDataForNoTokenTest() {
return RequestData.builder()
......
......@@ -15,17 +15,6 @@ public abstract class DeleteGroupTest extends AcceptanceBaseTest {
super(configurationService, tokenService);
}
@Override
protected RequestData getRequestDataForUnauthorizedTest() {
Token noAccessToken = tokenService.getNoDataAccessToken();
return RequestData.builder()
.method("DELETE")
.relativePath("groups/" + configurationService.getIdOfGroup("test"))
.dataPartitionId(configurationService.getTenantId())
.token(noAccessToken.getValue())
.build();
}
@Override
protected RequestData getRequestDataForNoTokenTest() {
return RequestData.builder()
......
......@@ -39,16 +39,6 @@ public abstract class DeleteMemberTest extends AcceptanceBaseTest {
}
}
@Override
protected RequestData getRequestDataForUnauthorizedTest() {
return RequestData.builder()
.method("DELETE")
.relativePath("members/member@test.com")
.dataPartitionId(configurationService.getTenantId())
.token(tokenService.getNoDataAccessToken().getValue())
.build();
}
@Override
protected RequestData getRequestDataForNoTokenTest() {
return RequestData.builder()
......
......@@ -22,16 +22,6 @@ public abstract class GetGroupsTest extends AcceptanceBaseTest {
Assert.assertEquals(token.getUserId(), listGroupResponse.getMemberEmail());
}
@Override
protected RequestData getRequestDataForUnauthorizedTest() {
Token noAccessToken = tokenService.getNoDataAccessToken();
return RequestData.builder()
.method("GET").dataPartitionId(configurationService.getTenantId())
.relativePath("groups")
.token(noAccessToken.getValue())
.build();
}
@Override
protected RequestData getRequestDataForNoTokenTest() {
return RequestData.builder()
......
......@@ -16,17 +16,6 @@ public abstract class GetMembersTest extends AcceptanceBaseTest {
super(configurationService, tokenService);
}
@Override
protected RequestData getRequestDataForUnauthorizedTest() {
Token noAccessToken = tokenService.getNoDataAccessToken();
final String groupEmail = configurationService.getIdOfGroup("group");
return RequestData.builder()
.method("GET").dataPartitionId(configurationService.getTenantId())
.relativePath(String.format("groups/%s/members", groupEmail))
.token(noAccessToken.getValue())
.build();
}
@Override
protected RequestData getRequestDataForNoTokenTest() {
final String groupEmail = configurationService.getIdOfGroup("group");
......
......@@ -16,17 +16,6 @@ public abstract class RemoveMemberTest extends AcceptanceBaseTest {
super(configurationService, tokenService);
}
@Override
protected RequestData getRequestDataForUnauthorizedTest() {
Token noAccessToken = tokenService.getNoDataAccessToken();
final String groupEmail = configurationService.getIdOfGroup("group");
return RequestData.builder()
.method("DELETE").dataPartitionId(configurationService.getTenantId())
.relativePath(String.format("groups/%s/members/%s", groupEmail, "member@test.com"))
.token(noAccessToken.getValue())
.build();
}
@Override
protected RequestData getRequestDataForNoTokenTest() {
final String groupEmail = configurationService.getIdOfGroup("group");
......
package org.opengroup.osdu.entitlements.v2.acceptance;
import com.google.gson.Gson;
import com.sun.jersey.api.client.ClientResponse;
import org.junit.Assert;
import org.junit.Test;
import org.opengroup.osdu.entitlements.v2.acceptance.model.Token;
import org.opengroup.osdu.entitlements.v2.acceptance.model.request.RequestData;
import org.opengroup.osdu.entitlements.v2.acceptance.model.response.UpdateGroupResponse;
import org.opengroup.osdu.entitlements.v2.acceptance.util.ConfigurationService;
import org.opengroup.osdu.entitlements.v2.acceptance.util.TokenService;
import java.util.HashSet;
import java.util.Set;
public abstract class TenantInitTest extends AcceptanceBaseTest {
public TenantInitTest(ConfigurationService configurationService, TokenService tokenService) {
super(configurationService, tokenService);
}
@Override
protected RequestData getRequestDataForUnauthorizedTest() {
Token noAccessToken = tokenService.getNoDataAccessToken();
return RequestData.builder()
.method("POST").dataPartitionId(configurationService.getTenantId())
.relativePath("tenant-provisioning")
.token(noAccessToken.getValue())
.build();
}
@Override
protected RequestData getRequestDataForNoTokenTest() {
return RequestData.builder()
......
......@@ -74,21 +74,6 @@ public abstract class UpdateGroupTest extends AcceptanceBaseTest {
entitlementsV2Service.deleteGroup(configurationService.getIdOfGroup("groupName-" + currentTime), token.getValue());
}
@Override
protected RequestData getRequestDataForUnauthorizedTest() {
Token noAccessToken = tokenService.getNoDataAccessToken();
UpdateGroupRequestData requestBody = UpdateGroupRequestData.builder()
.op("replace")
.path("/name")
.value(Collections.singletonList("newGroupName")).build();
return RequestData.builder()
.method("PATCH").dataPartitionId(configurationService.getTenantId())
.relativePath("groups/" + configurationService.getIdOfGroup("test"))
.body(new Gson().toJson(Collections.singletonList(requestBody)))
.token(noAccessToken.getValue())
.build();
}
@Override
protected RequestData getRequestDataForNoTokenTest() {
UpdateGroupRequestData requestBody = UpdateGroupRequestData.builder()
......
......@@ -5,5 +5,4 @@ import org.opengroup.osdu.entitlements.v2.acceptance.model.Token;
public interface TokenService {
Token getToken();
Token getNoDataAccessToken();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment