Skip to content

Commit

Permalink
#27302 minor fix and postman test
Browse files Browse the repository at this point in the history
  • Loading branch information
jdotcms committed Jan 11, 2024
1 parent 184f935 commit 453bd04
Show file tree
Hide file tree
Showing 2 changed files with 294 additions and 20 deletions.
272 changes: 272 additions & 0 deletions dotCMS/src/curl-test/EMA.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
{
"info": {
"_postman_id": "029879f9-ad5c-48a1-94b8-12f0369d3605",
"name": "EMA",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "781456"
},
"item": [
{
"name": "TestNoConfig",
"item": [
{
"name": "NoConfig",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"User FE has not access to EMA\", function () {",
" pm.response.to.have.status(404);",
"",
" ",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "basic",
"basic": [
{
"key": "password",
"value": "admin",
"type": "string"
},
{
"key": "username",
"value": "admin@dotcms.com",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{serverURL}}/api/v1/ema",
"host": [
"{{serverURL}}"
],
"path": [
"api",
"v1",
"ema"
]
}
},
"response": []
},
{
"name": "app-save Copy",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "basic",
"basic": [
{
"key": "password",
"value": "admin",
"type": "string"
},
{
"key": "username",
"value": "admin@dotCMS.com",
"type": "string"
},
{
"key": "saveHelperData",
"type": "any"
},
{
"key": "showPassword",
"value": false,
"type": "boolean"
}
]
},
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{ \n\t \"configuration\": {\n\t\t \"value\": \"{\\r\\n \\\"config\\\":[\\r\\n {\\r\\n \\\"pattern\\\":\\\"\\/blogs\\/(.*)\\\",\\r\\n \\\"url\\\":\\\"https:\\/\\/myspa.blogs.com:3000\\\",\\r\\n \\\"options\\\":{\\r\\n \\\"authenticationToken\\\":\\\"123\\\",\\r\\n \\\"depth\\\":3,\\r\\n \\\"X-CONTENT-APP\\\":\\\"dotCMS\\\"\\r\\n }\\r\\n },\\r\\n {\\r\\n \\\"pattern\\\":\\\".*\\\",\\r\\n \\\"url\\\":\\\"https:\\/\\/myspa.com:3000\\\",\\r\\n \\\"options\\\":{\\r\\n \\\"authenticationToken\\\":\\\"456\\\",\\r\\n \\\"depth\\\":1,\\r\\n \\\"X-CONTENT-APP\\\":\\\"dotCMS\\\"\\r\\n }\\r\\n }\\r\\n ]\\r\\n }\"\n }\n}\n"
},
"url": {
"raw": "{{serverURL}}/api/v1/apps/dotema-config-v2/8a7d5e23-da1e-420a-b4f0-471e7da8ea2d",
"host": [
"{{serverURL}}"
],
"path": [
"api",
"v1",
"apps",
"dotema-config-v2",
"8a7d5e23-da1e-420a-b4f0-471e7da8ea2d"
]
},
"description": "This tests the endpoint that brings back one specific App/integration given the App-key followed by the site-id"
},
"response": []
}
]
},
{
"name": "TestFrontEndAccess",
"item": [
{
"name": "CreateFrontEndUsers",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"User FE creation sucessfully\", function () {",
" pm.response.to.have.status(200);",
"",
" var jsonData = pm.response.json();",
" console.log(jsonData);",
"",
" pm.expect(jsonData[\"emailAddress\"]).to.eql(\"frontend2@dotcms.com\");",
" pm.expect(jsonData[\"firstName\"]).to.eql(\"FrontEnd\");",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "basic",
"basic": [
{
"key": "password",
"value": "admin",
"type": "string"
},
{
"key": "username",
"value": "admin@dotcms.com",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"userId\":\"userid-fe1-12345678\",\n \"active\":true,\n \"firstName\":\"FrontEnd\",\n \"middleName\":\"F\",\n \"lastName\":\"FE\",\n \"nickName\":\"FE\",\n \"email\":\"frontend2@dotcms.com\",\n \"male\":true,\n \"password\":[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\"],\n \"roles\":[\"DOTCMS_FRONT_END_USER\"]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{serverURL}}/api/v1/users",
"host": [
"{{serverURL}}"
],
"path": [
"api",
"v1",
"users"
]
}
},
"response": []
},
{
"name": "CallLogout",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{serverURL}}/dotAdmin/logout",
"host": [
"{{serverURL}}"
],
"path": [
"dotAdmin",
"logout"
]
}
},
"response": []
},
{
"name": "CheckEMAwithFEUserExpectedDenied",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"User FE has not access to EMA\", function () {",
" pm.response.to.have.status(401);",
"",
" ",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"auth": {
"type": "basic",
"basic": [
{
"key": "username",
"value": "frontend2@dotcms.com",
"type": "string"
},
{
"key": "password",
"value": "12345678",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{serverURL}}/api/v1/ema",
"host": [
"{{serverURL}}"
],
"path": [
"api",
"v1",
"ema"
]
}
},
"response": []
}
]
},
{
"name": "TestBeLimitedUser",
"item": []
}
]
}
42 changes: 22 additions & 20 deletions dotCMS/src/main/resources/apps/dotema-config-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,28 @@ params:
label: "Configuration"
hint: "Allows you to enter a JSON object that specifies how to match multiple URL patterns via RegExes with different 3rd party servers and rendering options, if required. For instance, in the following JSON object:<br/><br/>
```
[
{
\"pattern\":\"/blogs/(.*)\",
\"url\":\"https://myspa.blogs.com:3000\",
\"options\": {
\"authenticationToken\": \"123\",
\"depth\": 3,
\"X-CONTENT-APP\": \"dotCMS\"
}
},
{
\"pattern\":\".*\",
\"url\":\"https://myspa.com:3000\",
\"options\": {
\"authenticationToken\": \"456\",
\"depth\": 1,
\"X-CONTENT-APP\": \"dotCMS\"
}
}
]
{
"config":[
{
"pattern":"/blogs/(.*)",
"url":"https://myspa.blogs.com:3000",
"options":{
"authenticationToken":"123",
"depth":3,
"X-CONTENT-APP":"dotCMS"
}
},
{
"pattern":".*",
"url":"https://myspa.com:3000",
"options":{
"authenticationToken":"456",
"depth":1,
"X-CONTENT-APP":"dotCMS"
}
}
]
}
```<br/><br/>
You have a specific configuration for pages that start with '/blogs/' and a generic configuration for all other pages, i.e., '.*'. The 'options' object allows you to specify additional headers to be sent to the EMA Service. The 'authenticationToken' is an optional header in case you need a security layer for EMA requests. So, if the token sent by EMA does not equal the token in your app, the request will fail. The 'depth' attribute indicates dotCMS how many levels of related content must be returned by the API. The 'X-CONTENT-APP' is just an example of a custom header you can send to your app, so you can add your own."
required: true

0 comments on commit 453bd04

Please sign in to comment.