Skip to content

Commit bea64c6

Browse files
#1781 add retrieve test for script in folder whose name contains a slash
Co-authored-by: JoernBerkefeld <1917227+JoernBerkefeld@users.noreply.github.com>
1 parent b8f0916 commit bea64c6

5 files changed

Lines changed: 133 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"count": 1,
3+
"page": 1,
4+
"pageSize": 500,
5+
"items": [
6+
{
7+
"ssjsActivityId": "39f6a488-20eb-4ba0-b0b9-slashfolder",
8+
"name": "testExisting_slashFolderScript",
9+
"key": "testExisting_slashFolderScript",
10+
"description": "",
11+
"script": " <script runat=\"server\">\n//slashfolder\n</script>",
12+
"categoryId": 550,
13+
"createdDate": "2022-10-20T00:41:26.163",
14+
"modifiedDate": "2022-10-20T00:41:26.163"
15+
}
16+
]
17+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
5+
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
6+
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
7+
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
8+
<soap:Header>
9+
<wsa:Action>RetrieveResponse</wsa:Action>
10+
<wsa:MessageID>urn:uuid:f36f3303-3b5a-4641-8109-b26447634d91</wsa:MessageID>
11+
<wsa:RelatesTo>urn:uuid:33983968-28c4-4379-bb5f-f80ae32eb988</wsa:RelatesTo>
12+
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
13+
<wsse:Security>
14+
<wsu:Timestamp wsu:Id="Timestamp-32ecc81b-6020-473c-9e99-4b5338921220">
15+
<wsu:Created>2022-04-19T20:03:41Z</wsu:Created>
16+
<wsu:Expires>2022-04-19T20:08:41Z</wsu:Expires>
17+
</wsu:Timestamp>
18+
</wsse:Security>
19+
</soap:Header>
20+
<soap:Body>
21+
<RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
22+
<OverallStatus>OK</OverallStatus>
23+
<RequestID>02cd5ccb-8f84-4651-826f-71169eeecf05</RequestID>
24+
<Results xsi:type="DataFolder">
25+
<Client>
26+
<ID>9999999</ID>
27+
</Client>
28+
<PartnerKey xsi:nil="true" />
29+
<CreatedDate>2017-01-24T06:32:42.353</CreatedDate>
30+
<ModifiedDate>2017-01-24T06:32:42.353</ModifiedDate>
31+
<ID>304</ID>
32+
<ObjectID xsi:nil="true" />
33+
<CustomerKey>SSJSActivity_default</CustomerKey>
34+
<ParentFolder>
35+
<PartnerKey xsi:nil="true" />
36+
<ID>0</ID>
37+
<ObjectID xsi:nil="true" />
38+
</ParentFolder>
39+
<Name>Scripts</Name>
40+
<Description />
41+
<ContentType>SSJSActivity</ContentType>
42+
<IsActive>true</IsActive>
43+
<IsEditable>false</IsEditable>
44+
<AllowChildren>true</AllowChildren>
45+
</Results>
46+
<Results xsi:type="DataFolder">
47+
<Client>
48+
<ID>9999999</ID>
49+
</Client>
50+
<PartnerKey xsi:nil="true" />
51+
<CreatedDate>2022-10-20T00:41:26.353</CreatedDate>
52+
<ModifiedDate>2022-10-20T00:41:26.353</ModifiedDate>
53+
<ID>550</ID>
54+
<ObjectID xsi:nil="true" />
55+
<CustomerKey>SSJSActivity_slashfolder</CustomerKey>
56+
<ParentFolder>
57+
<PartnerKey xsi:nil="true" />
58+
<ID>304</ID>
59+
<ObjectID xsi:nil="true" />
60+
</ParentFolder>
61+
<Name>Headers/Folders</Name>
62+
<Description />
63+
<ContentType>SSJSActivity</ContentType>
64+
<IsActive>true</IsActive>
65+
<IsEditable>true</IsEditable>
66+
<AllowChildren>true</AllowChildren>
67+
</Results>
68+
</RetrieveResponseMsg>
69+
</soap:Body>
70+
</soap:Envelope>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"createdDate": "2022-10-20T00:41:26.163",
3+
"description": "",
4+
"key": "testExisting_slashFolderScript",
5+
"modifiedDate": "2022-10-20T00:41:26.163",
6+
"name": "testExisting_slashFolderScript",
7+
"r__folder_Path": "Scripts/Headers∕Folders"
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//slashfolder

test/type.folder.test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,43 @@ describe('type: folder', () => {
1818
testUtils.mockReset();
1919
});
2020

21+
describe('Retrieve ================', () => {
22+
it('Should retrieve a script whose folder name contains a slash and escape the slash in r__folder_Path', async () => {
23+
// GIVEN the SFMC folder "Headers/Folders" (child of Scripts) and a script in that folder
24+
await testUtils.copyFile(
25+
'dataFolder/+retrieve-ContentType=ssjsactivity-slashfolder-response.xml',
26+
'dataFolder/retrieve-ContentType=ssjsactivity-response.xml'
27+
);
28+
await testUtils.copyFile(
29+
'automation/v1/scripts/+get-slashfolder-response.json',
30+
'automation/v1/scripts/get-response.json'
31+
);
32+
33+
const retrieve = await handler.retrieve('testInstance/testBU', ['script']);
34+
// THEN
35+
assert.equal(process.exitCode, 0, 'retrieve should not have thrown an error');
36+
assert.equal(
37+
retrieve['testInstance/testBU'].script
38+
? Object.keys(retrieve['testInstance/testBU'].script).length
39+
: 0,
40+
1,
41+
'one script expected in retrieve response'
42+
);
43+
// Verify the retrieved script has the escape char (∕) in r__folder_Path, not a real slash
44+
assert.deepEqual(
45+
await testUtils.getActualJson('testExisting_slashFolderScript', 'script'),
46+
await testUtils.getExpectedJson('9999999', 'script', 'get_slashfolder'),
47+
'r__folder_Path should use ∕ (U+2215) to escape the slash in the folder name'
48+
);
49+
assert.equal(
50+
await testUtils.getActualFile('testExisting_slashFolderScript', 'script', 'ssjs'),
51+
await testUtils.getExpectedFile('9999999', 'script', 'get_slashfolder', 'ssjs'),
52+
'retrieved ssjs content should match expected'
53+
);
54+
return;
55+
});
56+
});
57+
2158
describe('Deploy ================', () => {
2259
it('Should create automation & dataExtension folders', async () => {
2360
// prepare

0 commit comments

Comments
 (0)