Skip to content

Commit f56d6e6

Browse files
author
Charles Greer
authored
Merge pull request #1357 from ayuwono/e2e/pii-final-data-verification
E2e/pii final data verification
2 parents 5c4fdc0 + 348aa52 commit f56d6e6

File tree

11 files changed

+195
-6
lines changed

11 files changed

+195
-6
lines changed

quick-start/e2e/page-objects/settings/settings.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ export class SettingsPage extends AppPage {
2424
get redeployButton() {
2525
return element(by.buttonText('Redeploy Hub'));
2626
}
27+
28+
get redeployConfirmation() {
29+
return element(by.buttonText('Redeploy'));
30+
}
31+
32+
get redeployStatus() {
33+
return element(by.cssContainingText('h3', 'Redeploy Status'));
34+
}
2735
}
2836

2937
var settingsPage = new SettingsPage();

quick-start/e2e/qa-data/plugins/contentWithOptions.sjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function extractInstanceProduct(source, opts) {
4949
}
5050
let sku = !fn.empty(source.sku || source.SKU) ? xs.string(fn.head(source.sku || source.SKU)) : null;
5151
let price = !fn.empty(source.price) ? xs.decimal(fn.head(source.xpath('//price'))) : null;
52-
let title = !fn.empty(source.title) ? xs.string(fn.head(source.title)) : null;
52+
let titlePii = !fn.empty(source.title) ? xs.string(fn.head(source.title)) : null;
5353
let value1 = !fn.empty(opts.hello) ? xs.string(fn.head(opts.hello)) : null;
5454
let value2 = !fn.empty(opts.myNumber) ? xs.string(fn.head(opts.myNumber)) : null;
5555

@@ -60,7 +60,7 @@ function extractInstanceProduct(source, opts) {
6060
'$version': '0.0.1',
6161
'sku': sku,
6262
'price': price,
63-
'title': title,
63+
'titlePii': titlePii,
6464
'opt1': value1,
6565
'opt2': value2
6666
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*~
2+
* Writer Plugin
3+
*
4+
* @param id - the identifier returned by the collector
5+
* @param envelope - the final envelope
6+
* @param options - an object options. Options are sent from Java
7+
*
8+
* @return - nothing
9+
*/
10+
function write(id, envelope, options) {
11+
let perms = [xdmp.permission("hub-admin-role", "read"), xdmp.permission("data-hub-role", "read")];
12+
xdmp.documentInsert(id, envelope, perms, options.entity);
13+
}
14+
15+
module.exports = write;
16+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"path-expression" : "/envelope/attachments//instance/title",
3+
"path-namespace" : [ ],
4+
"permission" : {
5+
"role-name" : "pii-reader",
6+
"capability" : "read"
7+
}
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"user-name": "no-pii-user",
3+
"description": "A user that cannot read pii property",
4+
"password": "x",
5+
"role": ["hub-admin-role", "data-hub-role"]
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"user-name": "pii-user",
3+
"description": "A user that can read pii property",
4+
"password": "x",
5+
"role": ["hub-admin-role", "data-hub-role", "pii-reader"]
6+
}

quick-start/e2e/specs/auth/authenticated.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ export default function(tmpDir) {
116116
fs.copy(flowAdminUserFilePath, tmpDir + '/src/main/ml-config/security/users/flow-admin-user.json');
117117
});
118118

119+
it ('should copy pii-user.json file', function() {
120+
//copy pii-user.json
121+
console.log('copy pii-user.json');
122+
let piiUserFilePath = 'e2e/qa-data/users/pii-user.json';
123+
fs.copy(piiUserFilePath, tmpDir + '/src/main/ml-config/security/users/pii-user.json');
124+
});
125+
126+
it ('should copy no-pii-user.json file', function() {
127+
//copy no-pii-user.json
128+
console.log('copy no-pii-user.json');
129+
let noPiiUserFilePath = 'e2e/qa-data/users/no-pii-user.json';
130+
fs.copy(noPiiUserFilePath, tmpDir + '/src/main/ml-config/security/users/no-pii-user.json');
131+
});
132+
119133
it ('Should be on the post init page', function() {
120134
expect(loginPage.projectDirTab.isDisplayed()).toBe(false);
121135
expect(loginPage.initIfNeededTab.isDisplayed()).toBe(false);

quick-start/e2e/specs/create/create.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import dashboardPage from '../../page-objects/dashboard/dashboard';
44
import entityPage from '../../page-objects/entities/entities';
55
import flowPage from '../../page-objects/flows/flows';
66
import appPage from '../../page-objects/appPage';
7+
import settingsPage from '../../page-objects/settings/settings';
8+
const fs = require('fs-extra');
79

810
const selectCardinalityOneToOneOption = 'select option:nth-child(1)';
911
const selectCardinalityOneToManyOption = 'select option:nth-child(2)';
1012

11-
export default function() {
13+
export default function(tmpDir) {
1214
describe('create entities', () => {
1315
beforeAll(() => {
1416
loginPage.isLoaded();
@@ -146,6 +148,14 @@ export default function() {
146148
entityPage.getPropertyType(lastProperty).element(by.cssContainingText('option', 'decimal')).click();
147149
entityPage.getPropertyDescription(lastProperty).sendKeys('price description');
148150
entityPage.getPropertyRangeIndex(lastProperty).click();
151+
// add titlePii property
152+
console.log('add titlePii property');
153+
entityPage.addProperty.click();
154+
lastProperty = entityPage.lastProperty;
155+
entityPage.getPropertyName(lastProperty).sendKeys('titlePii');
156+
entityPage.getPropertyType(lastProperty).element(by.cssContainingText('option', 'string')).click();
157+
entityPage.getPropertyDescription(lastProperty).sendKeys('titlePii description');
158+
entityPage.getPropertyPii(lastProperty).click();
149159
entityPage.saveEntity.click();
150160
browser.wait(EC.elementToBeClickable(entityPage.confirmDialogYesButton));
151161
expect(entityPage.confirmDialogYesButton.isPresent()).toBe(true);
@@ -209,6 +219,11 @@ export default function() {
209219
expect(entityPage.getPropertyType(priceProperty).getAttribute('value')).toContain('decimal');
210220
expect(entityPage.getPropertyDescription(priceProperty).getAttribute('value')).toEqual('price description');
211221
expect(entityPage.hasClass(entityPage.getPropertyRangeIndex(priceProperty), 'active')).toBe(true);
222+
let titlePiiProperty = entityPage.getPropertyByPosition(3);
223+
expect(entityPage.getPropertyName(titlePiiProperty).getAttribute('value')).toEqual('titlePii');
224+
expect(entityPage.getPropertyType(titlePiiProperty).getAttribute('value')).toContain('string');
225+
expect(entityPage.getPropertyDescription(titlePiiProperty).getAttribute('value')).toEqual('titlePii description');
226+
expect(entityPage.hasClass(entityPage.getPropertyPii(titlePiiProperty), 'active')).toBe(true);
212227
entityPage.cancelEntity.click();
213228
browser.wait(EC.invisibilityOf(entityPage.entityEditor));
214229
});
@@ -606,6 +621,25 @@ export default function() {
606621
browser.actions().dragAndDrop(entityPage.entityBox('WorldBank'), {x: 750, y: 750}).perform();
607622
});
608623

624+
it ('should copy attachment-pii.json file to protect title on attachment', function() {
625+
//copy attachment-pii.json
626+
console.log('copy attachment-pii.json');
627+
let attachmentPiiFilePath = 'e2e/qa-data/protected-paths/attachment-pii.json';
628+
fs.copy(attachmentPiiFilePath, tmpDir + '/src/main/ml-config/security/protected-paths/attachment-pii.json');
629+
});
630+
631+
it ('should redeploy hub to make the pii takes effect', function() {
632+
appPage.settingsTab.click();
633+
settingsPage.isLoaded();
634+
settingsPage.redeployButton.click();
635+
browser.wait(EC.elementToBeClickable(settingsPage.redeployConfirmation));
636+
settingsPage.redeployConfirmation.click();
637+
browser.wait(EC.visibilityOf(settingsPage.redeployStatus));
638+
expect(settingsPage.redeployStatus.isDisplayed()).toBe(true);
639+
browser.sleep(120000);
640+
browser.wait(EC.invisibilityOf(settingsPage.redeployStatus));
641+
});
642+
609643
it ('should go to the flow page', function() {
610644
appPage.flowsTab.click();
611645
flowPage.isLoaded();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import runCreate from './create'
22

3-
export default function () {
3+
export default function (tmpDir) {
44
describe('create', function () {
5-
runCreate()
5+
runCreate(tmpDir)
66
})
77
}

quick-start/e2e/specs/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('QuickStart', function () {
5757
});
5858

5959
auth(tmpobj.name);
60-
create();
60+
create(tmpobj.name);
6161
runFlows(tmpobj.name);
6262
jobs();
6363
runTraces();

0 commit comments

Comments
 (0)