Commit d61c61ef authored by harshit aggarwal's avatar harshit aggarwal
Browse files

Removing conflicts

parents 8a5df182 e9fd13ed
package org.opengroup.osdu.wks.provider.azure.credentials;
import org.opengroup.osdu.azure.util.AzureServicePrincipal;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.wks.provider.azure.di.AzureBootstrapConfig;
import org.opengroup.osdu.wks.provider.interfaces.UserCredential;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@Configuration
public class JwtTokenGenerator implements UserCredential {
private static final String BEARER = "Bearer ";
@Autowired
private AzureBootstrapConfig azureBootstrapConfig;
private AzureServicePrincipal azureServicePrincipal;
@Override
public String getIdToken(TenantInfo tenant) {
if(azureServicePrincipal == null) {
azureServicePrincipal = new AzureServicePrincipal();
}
String token = null;
try {
token = BEARER + azureServicePrincipal.getIdToken(
azureBootstrapConfig.getClientId(),
azureBootstrapConfig.getClientSecret(),
azureBootstrapConfig.getTenantId(),
azureBootstrapConfig.getAppResourceId());
}
catch (Exception e) {
System.out.println(e.getMessage());
}
return token;
}
}
package org.opengroup.osdu.wks.provider.azure.pubsub;
import com.microsoft.azure.servicebus.SubscriptionClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class SubscriptionClientFactory {
@Autowired
private SubscriptionClient subscriptionClient;
public SubscriptionClient getSubscriptionClient() {
return subscriptionClient;
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-wks</artifactId>
<version>0.0.1</version>
</parent>
<artifactId>wks-test-core</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>log4j-api</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>asm</artifactId>
<groupId>org.ow2.asm</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.0.11</version>
</dependency>
<dependency>
<groupId>com.github.berkesa</groupId>
<artifactId>datatree-core</artifactId>
<version>1.0.10</version>
</dependency>
<dependency>
<groupId>com.github.berkesa</groupId>
<artifactId>datatree-adapters</artifactId>
<version>1.0.11</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java8</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-guice</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opengroup.osdu.de</groupId>
<artifactId>os-automation-test-common-lib</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<version>0.0.17</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-wks-core</artifactId>
<version>0.0.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/groups/17/-/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/projects/191/packages/maven</url>
</repository>
<snapshotRepository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/projects/191/packages/maven</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<skipTests>${skipItTests}</skipTests>
<includes>
<include>org.opengroup.osdu.wks.runner.IntegrationTestRunner</include>
</includes>
</configuration>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>Default</id>
<properties>
<skipUnitTests>true</skipUnitTests>
<skipItTests>false</skipItTests>
<preIntegrationPhase>pre-integration-test</preIntegrationPhase>
<postIntegrationPhase>post-integration-test</postIntegrationPhase>
<mainClass>org.opengroup.osdu.wks.WksServiceApplication</mainClass>
</properties>
</profile>
</profiles>
</project>
\ No newline at end of file
package org.opengroup.osdu.wks.model;
public class AutomationConstants {
public static final String CONTENT_TYPE = "Content-Type";
public static final String DATA_PARTITION_ID = "data-partition-id";
public static final String AUTHORIZATION = "Authorization";
public static final String ON_BEHALF_OF = "on-behalf-of";
public static final String CORRELATION_ID = "correlation-id";
public static final String APPLICATION_JSON = "application/json";
public static final String APP_KEY = "AppKey";
public static final String TENANT = "opendes";
public static final String POST_ENDPOINT = "/records";
public static final String GET_ENDPOINT = "/records/";
public static final long RECORD_SEARCH_MAX_TIMEOUT_SEC = 30;
public static final String RECORD_CREATED = "201";
public static final String REQUEST_SUCCESS = "200";
public static final String RECORD_NOT_FOUND = "404";
public static final String MAPPING_MULTIPLE_FILE_FOUND = "Expected single mapping file";
public static final String MAPPING_NOT_PRESENT = "Mapping not present";
public static final String COLON_SEPARATOR = ":";
public static final String DASH = "-";
public static final String OS_WKS_SCHEMA_KIND = "opendes:wks:wellbore:1.0.0";
}
package org.opengroup.osdu.wks.model;
public class AutomationConstants {
public static final String CONTENT_TYPE = "Content-Type";
public static final String DATA_PARTITION_ID = "data-partition-id";
public static final String AUTHORIZATION = "Authorization";
public static final String ON_BEHALF_OF = "on-behalf-of";
public static final String CORRELATION_ID = "correlation-id";
public static final String APPLICATION_JSON = "application/json";
public static final String APP_KEY = "AppKey";
public static final String TENANT = "opendes";
public static final String POST_ENDPOINT = "/records";
public static final String GET_ENDPOINT = "/records/";
public static final String DELETE_ENDPOINT = "/records/";
public static final long RECORD_SEARCH_MAX_TIMEOUT_SEC = 30;
public static final String RECORD_CREATED = "201";
public static final String REQUEST_SUCCESS = "200";
public static final String REQUEST_SUCCESS_NO_CONTENT = "204";
public static final String RECORD_NOT_FOUND = "404";
public static final String MAPPING_MULTIPLE_FILE_FOUND = "Expected single mapping file";
public static final String MAPPING_NOT_PRESENT = "Mapping not present";
public static final String COLON_SEPARATOR = ":";
public static final String DASH = "-";
public static final String OS_WKS_SCHEMA_KIND = "opendes:wks:wellbore:1.0.0";
}
package org.opengroup.osdu.wks.model;
import java.util.List;
import java.util.Map;
import org.opengroup.osdu.de.automation.model.HttpResponse;
import org.opengroup.osdu.de.automation.util.FileUtils;
import com.google.inject.Inject;
import io.cucumber.guice.ScenarioScoped;
import lombok.Data;
@ScenarioScoped
public class WksIntegrationTestScope {
@Inject
private FileUtils fileUtils;
private String token;
private String inputPayload;
private HttpResponse httpResponse;
private Map<String, String> authHeaders;
private String wksRecordIdForCustomRawRecord;
private String customRecordId;
private String customValToVerifyUpdateOperation;
private String rawRecordWithVersionForAncestry;
private List<String> bulkRawRecordIdList;
public List<String> getBulkRawRecordIdList() {
return bulkRawRecordIdList;
}
public void setBulkRawRecordIdList(List<String> bulkRawRecordIdList) {
this.bulkRawRecordIdList = bulkRawRecordIdList;
}
public String getRawRecordWithVersionForAncestry() {
return rawRecordWithVersionForAncestry;
}
public void setRawRecordWithVersionForAncestry(String rawRecordWithVersionForAncestry) {
this.rawRecordWithVersionForAncestry = rawRecordWithVersionForAncestry;
}
public String getWksRecordIdForCustomRawRecord() {
return wksRecordIdForCustomRawRecord;
}
public void setWksRecordIdForCustomRawRecord(String wksRecordIdForCustomRawRecord) {
this.wksRecordIdForCustomRawRecord = wksRecordIdForCustomRawRecord;
}
public String getCustomValToVerifyUpdateOperation() {
return customValToVerifyUpdateOperation;
}
public void setCustomValToVerifyUpdateOperation(String customValToVerifyUpdateOperation) {
this.customValToVerifyUpdateOperation = customValToVerifyUpdateOperation;
}
public String getCustomRecordId() {
return customRecordId;
}
public void setCustomRecordId(String customRecordId) {
this.customRecordId = customRecordId;
}
public FileUtils getFileUtils() {
return fileUtils;
}
public void setFileUtils(FileUtils fileUtils) {
this.fileUtils = fileUtils;
}
public HttpResponse getHttpResponse() {
return httpResponse;
}
public void setHttpResponse(HttpResponse httpResponse) {
this.httpResponse = httpResponse;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getInputPayload() {
return inputPayload;
}
public void setInputPayload(String inputPayload) {
this.inputPayload = inputPayload;
}
public Map<String, String> getAuthHeaders() {
return authHeaders;
}
public void setAuthHeaders(Map<String, String> authHeaders) {
this.authHeaders = authHeaders;
}
}
package org.opengroup.osdu.wks.model;
import java.util.List;
import java.util.Map;
import org.opengroup.osdu.de.automation.model.HttpResponse;
import org.opengroup.osdu.de.automation.util.FileUtils;
import com.google.inject.Inject;
import io.cucumber.guice.ScenarioScoped;
import lombok.Data;
import org.opengroup.osdu.wks.util.AuthUtil;
@ScenarioScoped
public class WksIntegrationTestScope {
@Inject
private FileUtils fileUtils;
private String token;
private String inputPayload;
private HttpResponse httpResponse;
private Map<String, String> authHeaders;
private String wksRecordIdForCustomRawRecord;
private String customRecordId;
private String customValToVerifyUpdateOperation;
private String rawRecordWithVersionForAncestry;
private List<String> bulkRawRecordIdList;
private String vendor;
public List<String> getBulkRawRecordIdList() {
return bulkRawRecordIdList;
}
public void setBulkRawRecordIdList(List<String> bulkRawRecordIdList) {
this.bulkRawRecordIdList = bulkRawRecordIdList;
}
public String getRawRecordWithVersionForAncestry() {
return rawRecordWithVersionForAncestry;
}
public void setRawRecordWithVersionForAncestry(String rawRecordWithVersionForAncestry) {
this.rawRecordWithVersionForAncestry = rawRecordWithVersionForAncestry;
}
public String getWksRecordIdForCustomRawRecord() {
return wksRecordIdForCustomRawRecord;
}
public void setWksRecordIdForCustomRawRecord(String wksRecordIdForCustomRawRecord) {
this.wksRecordIdForCustomRawRecord = wksRecordIdForCustomRawRecord;
}
public String getCustomValToVerifyUpdateOperation() {
return customValToVerifyUpdateOperation;
}
public void setCustomValToVerifyUpdateOperation(String customValToVerifyUpdateOperation) {
this.customValToVerifyUpdateOperation = customValToVerifyUpdateOperation;
}
public String getCustomRecordId() {
return customRecordId;
}
public void setCustomRecordId(String customRecordId) {
this.customRecordId = customRecordId;
}
public FileUtils getFileUtils() {
return fileUtils;
}
public void setFileUtils(FileUtils fileUtils) {
this.fileUtils = fileUtils;
}
public HttpResponse getHttpResponse() {
return httpResponse;
}
public void setHttpResponse(HttpResponse httpResponse) {
this.httpResponse = httpResponse;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getInputPayload() {
return inputPayload;
}
public void setInputPayload(String inputPayload) {
this.inputPayload = inputPayload;
}
public Map<String, String> getAuthHeaders() {
return authHeaders;
}
public void setAuthHeaders(Map<String, String> authHeaders) {
this.authHeaders = authHeaders;
}
public void setVendor() {
this.vendor = System.getProperty("VENDOR", System.getenv("VENDOR"));
}
public String getVendor() {
return vendor;
}
}
package org.opengroup.osdu.wks.runner;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:features", glue = { "classpath:org.opengroup.osdu.wks.stepdefs" }, tags = {
"@WksService" }, plugin = { "pretty", "junit:target/cucumber-reports/wks-service-test-report.xml" })
public class IntegrationTestRunner {
}
package org.opengroup.osdu.wks.runner;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:features", glue = { "classpath:org.opengroup.osdu.wks.stepdefs" }, tags = {
"@WksService" }, plugin = { "pretty", "junit:target/cucumber-reports/wks-service-test-report.xml" })
public class IntegrationTestRunner {
}
package org.opengroup.osdu.wks.util;
import org.opengroup.osdu.azure.util.AzureServicePrincipal;
public class AuthUtil {
public synchronized String getToken() throws Exception {
String token = null;
String vendor = System.getProperty("VENDOR", System.getenv("VENDOR"));
switch (vendor) {
case "gcp":
// Token generation code for gcp comes here
break;
case "aws":
// Token generation code for aws comes here
break;
case "azure":
String clientId = System.getProperty("INTEGRATION_TESTER", System.getenv("INTEGRATION_TESTER"));
String clientSecret = System.getProperty("TESTER_SERVICEPRINCIPAL_SECRET", System.getenv("TESTER_SERVICEPRINCIPAL_SECRET"));
String tenantId = System.getProperty("AZURE_AD_TENANT_ID", System.getenv("AZURE_AD_TENANT_ID"));
String appResourceId = System.getProperty("AZURE_AD_APP_RESOURCE_ID", System.getenv("AZURE_AD_APP_RESOURCE_ID"));
token = new AzureServicePrincipal().getIdToken(clientId, clientSecret, tenantId, appResourceId);
break;
case "ibm":
// Token generation code for ibm comes here
break;
}
return "Bearer " + token;