Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions engine/src/main/resources/liquibase/changeSetPort.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@

<include file="port/20230626000000_mfe_communication_mediator_object.xml" relativeToChangelogFile="true" />

<include file="port/20231027000000_update_profile_types.xml" relativeToChangelogFile="true" />

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.4.xsd">

<changeSet id="20230626000000_mfe_communication_mediator_object.xml" author="entando" context="production">
<changeSet id="20230626000000_mfe_communication_mediator_object" author="entando" context="production">

<update tableName="pagemodels">
<column name="templategui" valueClobFile="clob/production/pagemodels_2_1.ftl" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.4.xsd">

<changeSet id="20231027000000_update_profile_types" author="entando" context="production">

<update tableName="sysconfig">
<column name="config" valueClobFile="clob/production/sysconfig_3_1.xml" />
<where>item='userProfileTypes'</where>
</update>

</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<profiletypes>
<profiletype typecode="PFL" typedescr="Default user profile">
<attributes>
<attribute name="fullname" attributetype="Monotext" description="Full Name" searchable="true">
<validations>
<required>true</required>
<regexp><![CDATA[^(?=.{2,70}$)[a-zA-ZÀ-ÿ0-9_-]{1}[a-zA-ZÀ-ÿ0-9 _-]*[a-zA-ZÀ-ÿ0-9_-]{1}$]]></regexp>
</validations>
<roles>
<role>userprofile:fullname</role>
</roles>
</attribute>
<attribute name="email" attributetype="Email" description="Email" searchable="true">
<validations>
<required>true</required>
</validations>
<roles>
<role>userprofile:email</role>
</roles>
</attribute>
<attribute name="profilepicture" attributetype="Monotext" description="Profile Picture" >
<roles>
<role>userprofile:profilepicture</role>
</roles>
</attribute>
</attributes>
</profiletype>
</profiletypes>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"code": "RX2",
"name": "Profile Type RX2",
"attributes": [
{
"code": "fullname",
"type": "Monotext",
"name": "Description of full name attribute",
"mandatory": false,
"validationRules": {
"regex":"^(?=.{2,70}$)[a-zA-ZÀ-ÿ0-9_-]{1}[a-zA-ZÀ-ÿ0-9 _-]*[a-zA-ZÀ-ÿ0-9_-]{1}$"
},
"roles": [{
"code": "userprofile:fullname",
"descr": "The Attribute containing the full name"
}]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "new_user",
"typeCode": "RX2",
"typeDescription": "Type for test",
"description": "Profile of user",
"mainGroup": "free",
"groups": [
"group1",
"group2"
],
"attributes": [
{
"code": "fullname",
"value": "Name"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "new_user",
"typeCode": "RX2",
"typeDescription": "Type for test RX2",
"description": "Profile of user",
"mainGroup": "free",
"groups": [
"group1",
"group2"
],
"attributes": [
{
"code": "fullname",
"value": "John Doe. "
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "new_user",
"typeCode": "RX2",
"typeDescription": "Type for test RX2",
"description": "Profile of user",
"mainGroup": "free",
"groups": [
"group1",
"group2"
],
"attributes": [
{
"code": "fullname",
"value": "John Doe"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.Arrays;
import java.util.Date;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
Expand Down Expand Up @@ -531,6 +532,75 @@ void testAddUserProfileWithProfilePicture() throws Exception {
}
}

@Test
void testPutMyProfileRegexAccept() throws Exception {
try {
Assertions.assertNull(this.userProfileManager.getEntityPrototype("RX2"));
String accessToken = this.createAccessToken();

this.executeProfileTypePost("13_POST_type_regex.json", accessToken, status().isOk());

Assertions.assertNotNull(this.userProfileManager.getEntityPrototype("RX2"));

this.executeProfilePost("13_POST_valid.json", accessToken, status().isOk()).andDo(resultPrint())
.andExpect(jsonPath("$.payload.id", is("new_user")))
.andExpect(jsonPath("$.errors.size()", is(0)))
.andExpect(jsonPath("$.metaData.size()", is(0)));

UserDetails userEditMyProfile = new OAuth2TestUtils.UserBuilder("new_user", "0x24")
.withAuthorization(Group.FREE_GROUP_NAME, "editor", Permission.ENTER_BACKEND)
.build();
String userEditMyProfileToken = mockOAuthInterceptor(userEditMyProfile);

this.executePutUpdateMyProfile("13_PUT_valid.json", userEditMyProfile, userEditMyProfileToken,
status().isOk())
.andExpect(jsonPath("$.payload.id", is("new_user")))
.andExpect(jsonPath("$.payload.typeCode", is("RX2")))
.andExpect(jsonPath("$.payload.typeDescription", is("Type for test RX2")));

} finally {
this.userManager.removeUser("new_user");
if (null != this.userProfileManager.getEntityPrototype("RX2")) {
((IEntityTypesConfigurer) this.userProfileManager).removeEntityPrototype("RX2");
}
Assertions.assertNull(this.userProfileManager.getEntityPrototype("RX2"));
}
}

@Test
void testPutMyProfileRegexReject() throws Exception {
try {
Assertions.assertNull(this.userProfileManager.getEntityPrototype("RX2"));
String accessToken = this.createAccessToken();

this.executeProfileTypePost("13_POST_type_regex.json", accessToken, status().isOk());

Assertions.assertNotNull(this.userProfileManager.getEntityPrototype("RX2"));

this.executeProfilePost("13_POST_valid.json", accessToken, status().isOk()).andDo(resultPrint())
.andExpect(jsonPath("$.payload.id", is("new_user")))
.andExpect(jsonPath("$.errors.size()", is(0)))
.andExpect(jsonPath("$.metaData.size()", is(0)));

UserDetails userEditMyProfile = new OAuth2TestUtils.UserBuilder("new_user", "0x24")
.withAuthorization(Group.FREE_GROUP_NAME, "editor", Permission.ENTER_BACKEND)
.build();
String userEditMyProfileToken = mockOAuthInterceptor(userEditMyProfile);

this.executePutUpdateMyProfile("13_PUT_invalid.json", userEditMyProfile, userEditMyProfileToken,
status().isBadRequest())
.andExpect(jsonPath("$.errors.size()", is(1)))
.andExpect(jsonPath("$.errors[0].message",
containsString("Attribute 'fullname' Invalid format")));
} finally {
this.userManager.removeUser("new_user");
if (null != this.userProfileManager.getEntityPrototype("RX2")) {
((IEntityTypesConfigurer) this.userProfileManager).removeEntityPrototype("RX2");
}
Assertions.assertNull(this.userProfileManager.getEntityPrototype("RX2"));
}
}

private String createAccessToken() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24")
.withAuthorization(Group.FREE_GROUP_NAME, "manageUserProfile", Permission.MANAGE_USER_PROFILES)
Expand Down