Skip to content
Snippets Groups Projects
Commit f4ebadef authored by Komal Makkar's avatar Komal Makkar
Browse files

Merge branch 'master' of...

Merge branch 'master' of https://community.opengroup.org/osdu/platform/system/notification into logs_jacoco_changes
parents c94ddca9 85cefc08
No related branches found
No related tags found
1 merge request!23Added UTs
Pipeline #10346 passed
/*
* Copyright 2017-2020, Schlumberger
* Copyright 2020 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* 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.
* Unless required by applicable law or agreed to in writing, software
* 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.
*/
package org.opengroup.osdu.notification.provider.ibm.security;
......@@ -24,11 +27,17 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
.httpBasic().disable()
.csrf().disable(); //disable default authN. AuthN handled by endpoints proxy
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests()
.antMatchers("/test/challenge/**",
"/v1/api-docs",
"/configuration/ui",
"/swagger-resources/**",
"/configuration/security",
"/swagger-ui.html",
"/webjars/**")
.permitAll().anyRequest().authenticated().and().oauth2ResourceServer().jwt();
}
}
\ No newline at end of file
......@@ -34,7 +34,7 @@ public class IBMServiceAccountValidatorImpl implements IServiceAccountValidator
//call isValidServiceAccount()
// Check whether IBM have to implement the service account verification for PubSub Role
// Marking it to return true, for the integration tests.
return true;
return false;
}
@Override
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2020 IBM Corp. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
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.
-->
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.opengroup.osdu</groupId>
<artifactId>notification-test-ibm</artifactId>
<version>1.0-SNAPSHOT</version>
<name>notification-test-ibm</name>
<description>Integration tests IBM for notification</description>
<packaging>jar</packaging>
<properties>
<java.version>8</java.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<os-core-lib-ibm.version>0.3.6-SNAPSHOT</os-core-lib-ibm.version>
</properties>
<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/143/packages/maven</url>
</repository>
<snapshotRepository>
<id>${gitlab-server}</id>
<url>https://community.opengroup.org/api/v4/projects/143/packages/maven</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-lib-ibm</artifactId>
<version>${os-core-lib-ibm.version}</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu.notification</groupId>
<artifactId>notification-test-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.3.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
</project>
package org.opengroup.osdu.notification.api;
import static org.junit.Assert.assertEquals;
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.opengroup.osdu.notification.util.IBMTestUtils;
import org.opengroup.osdu.notification.util.RestDescriptor;
import com.sun.jersey.api.client.ClientResponse;
public class TestPubsubEndpointGSA extends PubsubEndpointGSATests {
private static final IBMTestUtils gcpTestUtils = new IBMTestUtils();
@BeforeClass
public static void classSetup() throws Exception {
PubsubEndpointGSATests.classSetup(gcpTestUtils.getOpsToken());
}
@AfterClass
public static void classTearDown() throws Exception {
}
@Before
@Override
public void setup() throws Exception {
this.testUtils = new IBMTestUtils();
}
@After
@Override
public void tearDown() throws Exception {
this.testUtils = null;
}
@Override
public void should_return307_when_makingHttpRequest() throws Exception {
// No implementation for GSA in IBM
}
@Override
public void should_return20XResponseCode_when_makingValidHttpsRequest() throws Exception {
// No implementation for GSA in IBM
}
@Override
public void should_return20X_when_usingCredentialsWithOpsPermission() throws Exception{
}
@Override
public void should_returnOk_when_makingHttpOptionsRequest() throws Exception{
}
@Override
public void should_return400_when_makingHttpRequestWithoutToken() throws Exception {
ClientResponse response = descriptor.run(getArg(), "");
assertEquals(error( response.getEntity(String.class)), 401, response.getStatus());
}
}
\ No newline at end of file
package org.opengroup.osdu.notification.api;
import static org.junit.Assert.assertEquals;
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.opengroup.osdu.notification.util.IBMTestUtils;
import org.opengroup.osdu.notification.util.RestDescriptor;
import org.opengroup.osdu.notification.util.TestUtils;
import com.sun.jersey.api.client.ClientResponse;
public class TestPubsubEndpointHMAC extends PubsubEndpointHMACTests {
@BeforeClass
public static void classSetup() throws Exception {
PubsubEndpointHMACTests.classSetup();
}
@AfterClass
public static void classTearDown() throws Exception {
}
@Before
@Override
public void setup() throws Exception {
this.testUtils = new IBMTestUtils();
}
@After
@Override
public void tearDown() throws Exception {
this.testUtils = null;
}
@Override
public void should_return400_when_makingHttpRequestWithoutToken()throws Exception{
ClientResponse response = descriptor.run(getArg(), "");
assertEquals(error( response.getEntity(String.class)), 401, response.getStatus());
}
}
\ No newline at end of file
package org.opengroup.osdu.notification.util;
import org.opengroup.osdu.core.ibm.util.IdentityClient;
import com.google.common.base.Strings;
public class IBMTestUtils extends TestUtils {
public IBMTestUtils() {
}
@Override
public synchronized String getOpsToken() throws Exception {
if (Strings.isNullOrEmpty(opsToken)) {
opsToken=IdentityClient.getTokenForUserWithAccess();
}
return "Bearer " + opsToken;
}
@Override
public synchronized String getAdminToken() throws Exception {
if(Strings.isNullOrEmpty(adminToken)) {
adminToken = IdentityClient.getTokenForUserWithAccess();
}
return adminToken;
}
@Override
public synchronized String getEditorToken() throws Exception {
if(Strings.isNullOrEmpty(editorToken)) {
editorToken = IdentityClient.getTokenForUserWithAccess();
}
return editorToken;
}
@Override
public synchronized String getNoAccessToken() throws Exception {
if(Strings.isNullOrEmpty(noAccessToken)) {
noAccessToken = IdentityClient.getTokenForUserWithNoAccess();
}
return noAccessToken;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment