diff options
author | Dan Timoney <dt5972@att.com> | 2018-09-21 13:18:44 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-09-21 13:18:44 +0000 |
commit | d0bd315216af0b0f1171b6e20de84801fe382681 (patch) | |
tree | 052fef2997c071fcea27a5b816e6f50d6952bee9 /ms/controllerblueprints/application/src/test | |
parent | 35b6e21234485e4ddc75d09cf828c783a30bea56 (diff) | |
parent | c5fd649dc92ead7a0de25a668beb0d5d10337381 (diff) |
Merge "Controller Blueprints Microservice"
Diffstat (limited to 'ms/controllerblueprints/application/src/test')
3 files changed, 24 insertions, 25 deletions
diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java index 61b5c50f..7a5f952d 100644 --- a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java +++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java @@ -1,6 +1,6 @@ /*
* Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ *
* 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
@@ -16,8 +16,6 @@ package org.onap.ccsdk.apps.controllerblueprints;
-import static org.assertj.core.api.Assertions.assertThat;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -27,56 +25,40 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
+import org.springframework.http.*;
+import org.springframework.http.client.support.BasicAuthorizationInterceptor;
import org.springframework.test.context.junit4.SpringRunner;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class ControllerBluprintsApplicationTest {
- private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBluprintsApplicationTest.class);
-
@Autowired
private TestRestTemplate restTemplate;
- private HttpHeaders headers;
- private ResponseEntity<ConfigModel> entity;
@Before
public void setUp(){
- headers = new HttpHeaders();
- headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
- entity = this.restTemplate
- .exchange("/api/v1/config-model/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);
-
+ BasicAuthorizationInterceptor bai = new BasicAuthorizationInterceptor("ccsdkapps", "ccsdkapps");
+ this.restTemplate.getRestTemplate().getInterceptors().add(bai);
}
@Test
public void testConfigModel() {
-
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
ResponseEntity<ConfigModel> entity = this.restTemplate
.exchange("/api/v1/config-model/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);
-
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
Assert.assertNotNull("failed to get response Config model",entity.getBody());
}
@Test
public void testConfigModelFailure() {
-
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
ResponseEntity<ConfigModel> entity = this.restTemplate
.exchange("/api/v1/config-model-not-found/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);
-
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
Assert.assertNotNull("failed to get response Config model",entity.getBody());
}
diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java index 9445e1d3..995644fd 100644 --- a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java +++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java @@ -16,21 +16,34 @@ package org.onap.ccsdk.apps.controllerblueprints;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Test;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+
/**
* VersionSplitTest
*
* @author Brinda Santh
*/
public class VersionSplitTest {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(VersionSplitTest.class);
@Test
public void testVersionSplit() {
String version = "1.03.04";
String[] tokens = StringUtils.split(version, '.');
Assert.assertNotNull("failed to tokenize", tokens);
- Assert.assertEquals("failed to three token ", 3, tokens.length );
+ Assert.assertEquals("failed to three token ", 3, tokens.length);
+ }
+
+ @Test
+ public void encodeTest() {
+ String name = "ccsdkapps";
+ BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
+ String encodedValue = bCryptPasswordEncoder.encode(name);
+ Assert.assertTrue("Failed to match", bCryptPasswordEncoder.matches(name, encodedValue));
}
}
\ No newline at end of file diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index 5c6acf93..e812da5c 100644 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -20,6 +20,10 @@ appName=ControllerBluePrints ms_name=org.onap.ccsdk.apps.controllerblueprints
appVersion=1.0.0
+# Basic Authentication
+basic-auth.user-name=ccsdkapps
+basic-auth.hashed-pwd=$2a$10$MJxhNiOAffxbyrV9.rrOUewP9Q/ASg5Nit2cmP.yBaXGsVXo8BW3y
+
#To Remove Null in JSON API Response
spring.jackson.default-property-inclusion=non_null
|