Commit a11993ab authored by Riabokon Stanislav(EPAM)[GCP]'s avatar Riabokon Stanislav(EPAM)[GCP]
Browse files

Partion service as tenantinfo provider (GONRG-2498)

parent 5d67a219
......@@ -72,6 +72,7 @@ The following software have components provided under the terms of this license:
- AssertJ fluent assertions (from )
- Asynchronous Http Client (from )
- Asynchronous Http Client Netty Utils (from )
- AutoValue Annotations (from )
- Azure AD Spring Security Integration Spring Boot Starter (from https://github.com/Microsoft/azure-spring-boot)
- Azure Metrics Spring Boot Starter (from https://github.com/Microsoft/azure-spring-boot)
- Bean Validation API (from http://beanvalidation.org)
......@@ -86,6 +87,7 @@ The following software have components provided under the terms of this license:
- Expression Language 3.0 (from http://uel.java.net)
- Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el)
- FindBugs-jsr305 (from http://findbugs.sourceforge.net/)
- GSON extensions to the Google HTTP Client Library for Java. (from )
- Google APIs Client Library for Java (from )
- Google App Engine extensions to the Google HTTP Client Library for Java. (from )
- Google Cloud Core (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-core)
......@@ -753,6 +755,7 @@ unknown
The following software have components provided under the terms of this license:
- Byte Buddy (without dependencies) (from )
- Checker Qual (from https://checkerframework.org)
- Common Annotations 1.2 API (from )
- JUnit (from http://junit.org)
- JUnit Jupiter (Aggregator) (from https://junit.org/junit5/)
......
......@@ -31,6 +31,7 @@ In order to run the service locally or remotely, you will need to have the follo
| `APP_REGISTER` | ex `https://register.com/api/register/v1` | Storage API endpoint | no | output of infrastructure deployment |
| `APP_PROJECT` | ex `opendes` | Google Cloud Project Id | no | output of infrastructure deployment |
| `APP_AUDIENCES` | ex `*****.apps.googleusercontent.com` | Client ID for getting access to cloud resources | yes | https://console.cloud.google.com/apis/credentials |
| `PARTITION_API` | ex `http://localhost:8081/api/partition/v1` | Partition service endpoint | no | - |
**System Environment required to run service**
......
......@@ -40,11 +40,12 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.9.0-rc17</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-gcp</artifactId>
<version>0.7.0</version>
<version>0.9.0-SNAPSHOT</version>
</dependency>
<dependency>
......
......@@ -20,9 +20,11 @@ import org.opengroup.osdu.notification.provider.gcp.util.AppProperties;
import org.opengroup.osdu.notification.provider.gcp.util.ServiceAccountJwtGcpClientImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
@Component
@Primary
public class ServiceAccountJwtClientFactory extends AbstractFactoryBean<IServiceAccountJwtClient> {
@Autowired
......
......@@ -19,4 +19,7 @@ logging.level.org.springframework.web=${LOG_LEVEL:DEBUG}
server.servlet.contextPath=/
app.expireTime=300
app.maxCacheSize=10
server.error.whitelabel.enabled=false
\ No newline at end of file
server.error.whitelabel.enabled=false
google.audiences=${APP_AUDIENCES}
partition.api=http://localhost:8081/api/partition/v1
\ No newline at end of file
package org.opengroup.osdu.notification.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.sun.jersey.api.client.ClientResponse;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.opengroup.osdu.notification.util.Config;
import org.junit.Test;
import org.opengroup.osdu.notification.util.GCPTestUtils;
import org.opengroup.osdu.notification.util.RestDescriptor;
public class TestPubsubEndpointGSA extends PubsubEndpointGSATests {
private static final GCPTestUtils gcpTestUtils = new GCPTestUtils();
private static final GCPTestUtils gcpTestUtils = new GCPTestUtils();
@BeforeClass
public static void classSetup() throws Exception {
PubsubEndpointGSATests.classSetup(gcpTestUtils.getOpsToken());
}
@BeforeClass
public static void classSetup() throws Exception {
PubsubEndpointGSATests.classSetup(gcpTestUtils.getOpsToken());
}
@AfterClass
public static void classTearDown() throws Exception {
}
@AfterClass
public static void classTearDown() throws Exception {
}
@Before
@Override
public void setup() throws Exception {
this.testUtils = new GCPTestUtils();
}
@Before
@Override
public void setup() throws Exception {
this.testUtils = new GCPTestUtils();
}
@After
@Override
public void tearDown() throws Exception {
this.testUtils = null;
}
@Override
@Test
public void should_return20X_when_usingCredentialsWithOpsPermission() throws Exception {
createResource();
try {
ClientResponse response = descriptor.run(getArg(), testUtils.getOpsToken());
@After
@Override
public void tearDown() throws Exception {
this.testUtils = null;
assertEquals(error(response.getStatus() == 204 ? "" : response.getEntity(String.class)),
expectedOkResponseCode(), response.getStatus());
assertEquals("GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH",
response.getHeaders().getFirst("Access-Control-Allow-Methods"));
assertEquals(
"access-control-allow-origin, origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey",
response.getHeaders().getFirst("Access-Control-Allow-Headers"));
assertEquals("*", response.getHeaders().getFirst("Access-Control-Allow-Origin"));
assertEquals("true", response.getHeaders().getFirst("Access-Control-Allow-Credentials"));
assertEquals("DENY", response.getHeaders().getFirst("X-Frame-Options"));
assertEquals("1; mode=block", response.getHeaders().getFirst("X-XSS-Protection"));
assertEquals("nosniff", response.getHeaders().getFirst("X-Content-Type-Options"));
assertEquals("no-cache, no-store, must-revalidate",
response.getHeaders().getFirst("Cache-Control"));
assertEquals("default-src 'self'", response.getHeaders().getFirst("Content-Security-Policy"));
assertTrue(response.getHeaders().get("Strict-Transport-Security").get(0)
.contains("max-age=31536000"));
assertTrue(response.getHeaders().get("Strict-Transport-Security").get(0)
.contains("includeSubDomains"));
assertEquals("0", response.getHeaders().getFirst("Expires"));
} finally {
deleteResource();
}
}
}
\ No newline at end of file
package org.opengroup.osdu.notification.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.sun.jersey.api.client.ClientResponse;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.opengroup.osdu.notification.util.Config;
import org.junit.Test;
import org.opengroup.osdu.notification.util.GCPTestUtils;
import org.opengroup.osdu.notification.util.RestDescriptor;
import org.opengroup.osdu.notification.util.TestUtils;
public class TestPubsubEndpointHMAC extends PubsubEndpointHMACTests {
@BeforeClass
public static void classSetup() throws Exception {
PubsubEndpointHMACTests.classSetup();
}
@BeforeClass
public static void classSetup() throws Exception {
PubsubEndpointHMACTests.classSetup();
}
@AfterClass
public static void classTearDown() throws Exception {
}
@AfterClass
public static void classTearDown() throws Exception {
}
@Before
@Override
public void setup() throws Exception {
this.testUtils = new GCPTestUtils();
}
@Before
@Override
public void setup() throws Exception {
this.testUtils = new GCPTestUtils();
}
@After
@Override
public void tearDown() throws Exception {
this.testUtils = null;
}
@Override
@Test
public void should_return20X_when_usingCredentialsWithOpsPermission() throws Exception {
createResource();
try {
ClientResponse response = descriptor.run(getArg(), testUtils.getOpsToken());
@After
@Override
public void tearDown() throws Exception {
this.testUtils = null;
assertEquals(error(response.getStatus() == 204 ? "" : response.getEntity(String.class)),
expectedOkResponseCode(), response.getStatus());
assertEquals("GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH",
response.getHeaders().getFirst("Access-Control-Allow-Methods"));
assertEquals(
"access-control-allow-origin, origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey",
response.getHeaders().getFirst("Access-Control-Allow-Headers"));
assertEquals("*", response.getHeaders().getFirst("Access-Control-Allow-Origin"));
assertEquals("true", response.getHeaders().getFirst("Access-Control-Allow-Credentials"));
assertEquals("DENY", response.getHeaders().getFirst("X-Frame-Options"));
assertEquals("1; mode=block", response.getHeaders().getFirst("X-XSS-Protection"));
assertEquals("nosniff", response.getHeaders().getFirst("X-Content-Type-Options"));
assertEquals("no-cache, no-store, must-revalidate",
response.getHeaders().getFirst("Cache-Control"));
assertEquals("default-src 'self'", response.getHeaders().getFirst("Content-Security-Policy"));
assertTrue(response.getHeaders().get("Strict-Transport-Security").get(0)
.contains("max-age=31536000"));
assertTrue(response.getHeaders().get("Strict-Transport-Security").get(0)
.contains("includeSubDomains"));
assertEquals("0", response.getHeaders().getFirst("Expires"));
} finally {
deleteResource();
}
}
}
\ No newline at end of file
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