summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoop Talasila <talasila@research.att.com>2019-08-28 18:52:21 +0000
committerGerrit Code Review <gerrit@onap.org>2019-08-28 18:52:21 +0000
commit8089e86923f13f2df0f1b234be3f0771a3044d4d (patch)
tree8915221d39eb98daa53f17854231567e1349cfdb
parent19155f5cde7703be3449050b57d90554836271af (diff)
parent88db33c6a8e2a03e72a0c676f51937418ee84912 (diff)
Merge "Postman tests up"
-rw-r--r--portal-BE/deliveries/postman/Portal.postman_collection.json267
-rw-r--r--portal-BE/src/main/java/org/onap/portal/configuration/SecurityConfig.java4
-rw-r--r--portal-BE/src/main/java/org/onap/portal/controller/LanguageController.java5
-rw-r--r--portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java6
-rw-r--r--portal-BE/src/main/resources/application.properties2
5 files changed, 278 insertions, 6 deletions
diff --git a/portal-BE/deliveries/postman/Portal.postman_collection.json b/portal-BE/deliveries/postman/Portal.postman_collection.json
new file mode 100644
index 00000000..e0b51e9e
--- /dev/null
+++ b/portal-BE/deliveries/postman/Portal.postman_collection.json
@@ -0,0 +1,267 @@
+{
+ "info": {
+ "_postman_id": "1c6e52dd-039b-400b-a986-49d25e5a1428",
+ "name": "Portal",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
+ },
+ "item": [
+ {
+ "name": "LanguageController",
+ "item": [
+ {
+ "name": "localhost:8080/auxapi/languageSetting/user/2",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "2fc1aa20-6048-4500-bdd2-5b2cc070f27c",
+ "exec": [
+ "pm.test(\"Status code is 200\", function () {",
+ " pm.response.to.have.status(200);",
+ "});",
+ "pm.test(\"Response time is less than 200ms\", function () {",
+ " pm.expect(pm.response.responseTime).to.be.below(200);",
+ "});"
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "password",
+ "value": "4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=",
+ "type": "string"
+ },
+ {
+ "key": "username",
+ "value": "demo",
+ "type": "string"
+ }
+ ]
+ },
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "localhost:8080/auxapi/languageSetting/user/2",
+ "host": [
+ "localhost"
+ ],
+ "port": "8080",
+ "path": [
+ "auxapi",
+ "languageSetting",
+ "user",
+ "2"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "localhost:8080/auxapi/language",
+ "request": {
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "localhost:8080/auxapi/language",
+ "host": [
+ "localhost"
+ ],
+ "port": "8080",
+ "path": [
+ "auxapi",
+ "language"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "localhost:8080/auxapi/language",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "2fc1aa20-6048-4500-bdd2-5b2cc070f27c",
+ "exec": [
+ "pm.test(\"Status code is 200\", function () {",
+ " pm.response.to.have.status(200);",
+ "});",
+ "pm.test(\"Response time is less than 200ms\", function () {",
+ " pm.expect(pm.response.responseTime).to.be.below(200);",
+ "});"
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "password",
+ "value": "4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=",
+ "type": "string"
+ },
+ {
+ "key": "username",
+ "value": "demo",
+ "type": "string"
+ }
+ ]
+ },
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "name": "Content-Type",
+ "value": "application/json",
+ "type": "text"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"languageName\": \"PL\",\n \"languageAlias\": \"Polish\"\n}"
+ },
+ "url": {
+ "raw": "localhost:8080/auxapi/language",
+ "host": [
+ "localhost"
+ ],
+ "port": "8080",
+ "path": [
+ "auxapi",
+ "language"
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "localhost:8080/auxapi/language",
+ "event": [
+ {
+ "listen": "test",
+ "script": {
+ "id": "2fc1aa20-6048-4500-bdd2-5b2cc070f27c",
+ "exec": [
+ "pm.test(\"Status code is 200\", function () {",
+ " pm.response.to.have.status(200);",
+ "});",
+ "",
+ "pm.test(\"Response time is less than 200ms\", function () {",
+ " pm.expect(pm.response.responseTime).to.be.below(200);",
+ "});",
+ "",
+ "var customer = JSON.parse(responseBody);",
+ "",
+ "tests[\"Message is valid\"] = customer.message === \"FAILURE\"",
+ "tests[\"Status is valid\"] = customer.status === \"ERROR\"",
+ "tests[\"Response is valid\"] = customer.response === \"FnLanguage is not valid, may have unsafe html content\""
+ ],
+ "type": "text/javascript"
+ }
+ }
+ ],
+ "request": {
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "password",
+ "value": "4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=",
+ "type": "string"
+ },
+ {
+ "key": "username",
+ "value": "demo",
+ "type": "string"
+ }
+ ]
+ },
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "name": "Content-Type",
+ "value": "application/json",
+ "type": "text"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"languageName\": \"PL\",\n \"languageAlias\": \"<script>alert(“XSS”)</script>\"\n}"
+ },
+ "url": {
+ "raw": "localhost:8080/auxapi/language",
+ "host": [
+ "localhost"
+ ],
+ "port": "8080",
+ "path": [
+ "auxapi",
+ "language"
+ ]
+ },
+ "description": "XSS test"
+ },
+ "response": []
+ }
+ ],
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "password",
+ "value": "4Gl6WL1bmwviYm+XZa6pS1vC0qKXWtn9wcZWdLx61L0=",
+ "type": "string"
+ },
+ {
+ "key": "username",
+ "value": "demo",
+ "type": "string"
+ }
+ ]
+ }
+ },
+ {
+ "name": "http://localhost:8080/logout",
+ "request": {
+ "auth": {
+ "type": "noauth"
+ },
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "http://localhost:8080/logout",
+ "protocol": "http",
+ "host": [
+ "localhost"
+ ],
+ "port": "8080",
+ "path": [
+ "logout"
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+} \ No newline at end of file
diff --git a/portal-BE/src/main/java/org/onap/portal/configuration/SecurityConfig.java b/portal-BE/src/main/java/org/onap/portal/configuration/SecurityConfig.java
index c73f7d57..b9e60334 100644
--- a/portal-BE/src/main/java/org/onap/portal/configuration/SecurityConfig.java
+++ b/portal-BE/src/main/java/org/onap/portal/configuration/SecurityConfig.java
@@ -83,7 +83,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.permitAll()
.and()
.logout()
- .permitAll();
+ .permitAll()
+ .and()
+ .httpBasic();
http.csrf().disable();
http.headers().frameOptions().disable();
diff --git a/portal-BE/src/main/java/org/onap/portal/controller/LanguageController.java b/portal-BE/src/main/java/org/onap/portal/controller/LanguageController.java
index 2ea4ff24..97fe03da 100644
--- a/portal-BE/src/main/java/org/onap/portal/controller/LanguageController.java
+++ b/portal-BE/src/main/java/org/onap/portal/controller/LanguageController.java
@@ -54,6 +54,7 @@ import org.onap.portal.service.fn.FnUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -102,8 +103,8 @@ public class LanguageController {
return new FnLanguage();
}
- @PostMapping(value = "/language")
- public PortalRestResponse<String> saveLanguage(final Principal principal, final FnLanguage fnLanguage){
+ @PostMapping(value = "/language", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
+ public PortalRestResponse<String> saveLanguage(final Principal principal, @RequestBody final FnLanguage fnLanguage){
PortalRestResponse<String> response = new PortalRestResponse<>();
try {
response.setMessage("SUCCESS");
diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java
index 09cb5a6e..996929e7 100644
--- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java
+++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnLanguage.java
@@ -40,6 +40,7 @@
package org.onap.portal.domain.db.fn;
+import com.fasterxml.jackson.annotation.JsonInclude;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -72,6 +73,7 @@ CREATE TABLE `fn_language` (
@Getter
@Setter
@Entity
+@JsonInclude()
@SequenceGenerator(name="seq", initialValue=3, allocationSize=100)
public class FnLanguage {
@@ -82,12 +84,12 @@ public class FnLanguage {
private Long languageId;
@Column(name = "language_name", length = 100, nullable = false)
@Size(max = 100)
- @NotNull
+ @NotNull(message = "languageName must not be null")
@SafeHtml
private String languageName;
@Column(name = "language_alias", length = 100, nullable = false)
@Size(max = 100)
- @NotNull
+ @NotNull(message = "languageAlias must not be null")
@SafeHtml
private String languageAlias;
diff --git a/portal-BE/src/main/resources/application.properties b/portal-BE/src/main/resources/application.properties
index eb346eef..f3db0623 100644
--- a/portal-BE/src/main/resources/application.properties
+++ b/portal-BE/src/main/resources/application.properties
@@ -1,4 +1,4 @@
-server.port=8090
+server.port=8080
spring.datasource.url=jdbc:mysql://localhost:3306/testdb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver