aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
authorMax Benjamin <max.benjamin@att.com>2020-02-14 14:50:16 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-14 14:50:16 +0000
commit460b2c35e214b9422e9313a4bad8253669791ebf (patch)
treeec16d302fa24fa1a9929e881d6b4a91551008c6b /adapters
parentdbf7a49c67050dbd132146e4fa230bb5723dbc7d (diff)
parent361511c01e4e51dddb6e3bfe11b6728a76dbbfd0 (diff)
Merge "Fixed, simplified and tested AuthorizationHeadersProvider (+small changes in poms)"
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-ve-vnfm-adapter/pom.xml11
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/provider/AuthorizationHeadersProvider.java20
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java2
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/provider/AuthorizationHeadersProviderTest.java47
4 files changed, 62 insertions, 18 deletions
diff --git a/adapters/mso-ve-vnfm-adapter/pom.xml b/adapters/mso-ve-vnfm-adapter/pom.xml
index 3518445b45..4472956eb7 100644
--- a/adapters/mso-ve-vnfm-adapter/pom.xml
+++ b/adapters/mso-ve-vnfm-adapter/pom.xml
@@ -59,10 +59,21 @@
</dependencies>
<build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+ <mainClass>org.onap.so.adapters.vevnfm.Application</mainClass>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
</plugins>
</build>
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/provider/AuthorizationHeadersProvider.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/provider/AuthorizationHeadersProvider.java
index eca5240cb5..251e0c426b 100644
--- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/provider/AuthorizationHeadersProvider.java
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/provider/AuthorizationHeadersProvider.java
@@ -20,29 +20,15 @@
package org.onap.so.adapters.vevnfm.provider;
-import java.util.List;
-import org.apache.logging.log4j.util.Strings;
import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
-import org.springframework.http.HttpHeaders;
public class AuthorizationHeadersProvider extends BasicHttpHeadersProvider {
- private List<String> previousAuthorization;
-
public void addAuthorization(final String authorization) {
- final HttpHeaders headers = getHttpHeaders();
- previousAuthorization = headers.get(AUTHORIZATION_HEADER);
- headers.set(AUTHORIZATION_HEADER, authorization);
- }
-
- public void resetPrevious() {
- if (!isPreviousAuthorizationBlank()) {
- getHttpHeaders().addAll(AUTHORIZATION_HEADER, previousAuthorization);
- }
+ getHttpHeaders().set(AUTHORIZATION_HEADER, authorization);
}
- private boolean isPreviousAuthorizationBlank() {
- return previousAuthorization == null || previousAuthorization.isEmpty()
- || Strings.isBlank(previousAuthorization.get(0));
+ public void removeAuthorization() {
+ getHttpHeaders().remove(AUTHORIZATION_HEADER);
}
}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java
index 0e77ce4073..eefd9ba93b 100644
--- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java
@@ -68,7 +68,7 @@ public class SubscriberService {
final LccnSubscriptionRequest request = createRequest();
return sender.send(info, request);
} finally {
- headersProvider.resetPrevious();
+ headersProvider.removeAuthorization();
}
}
diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/provider/AuthorizationHeadersProviderTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/provider/AuthorizationHeadersProviderTest.java
new file mode 100644
index 0000000000..64503ddfc2
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/provider/AuthorizationHeadersProviderTest.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vevnfm.provider;
+
+import static org.junit.Assert.*;
+import static org.onap.so.configuration.rest.BasicHttpHeadersProvider.AUTHORIZATION_HEADER;
+import org.junit.Test;
+import org.springframework.http.HttpHeaders;
+
+public class AuthorizationHeadersProviderTest {
+
+ private static final String AUTHORIZATION_EXAMPLE = "authorization";
+
+ private final AuthorizationHeadersProvider provider = new AuthorizationHeadersProvider();
+
+ @Test
+ public void testSuccessValidAuthorizationAndRemoval() {
+ final HttpHeaders headers = provider.getHttpHeaders();
+ final int size = headers.size();
+
+ provider.addAuthorization(AUTHORIZATION_EXAMPLE);
+ assertEquals(size + 1, headers.size());
+ assertTrue(headers.containsKey(AUTHORIZATION_HEADER));
+
+ provider.removeAuthorization();
+ assertEquals(size, headers.size());
+ assertFalse(headers.containsKey(AUTHORIZATION_HEADER));
+ }
+}