Postman tests up

Postman tests up

Issue-ID: PORTAL-710
Change-Id: I2bdb4ba12b35f7c17014eff2a68fd5534e307bbd
Signed-off-by: Dominik Mizyn <d.mizyn@samsung.com>
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 0000000..e0b51e9
--- /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 c73f7d5..b9e6033 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 @@
                       .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 2ea4ff2..97fe03d 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.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 @@
               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 09cb5a6..996929e 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 @@
 @Getter
 @Setter
 @Entity
+@JsonInclude()
 @SequenceGenerator(name="seq", initialValue=3, allocationSize=100)
 public class FnLanguage {
 
@@ -82,12 +84,12 @@
        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 eb346ee..f3db062 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