Skip to content

Commit e9579ef

Browse files
committed
test(e2e): grant catch-all OCAPI permissions to shared test sandbox
The e2e shared-sandbox hook relied on the CLI's DEFAULT_OCAPI_RESOURCES, which omits /sites and /jobs/*/executions/* search endpoints. Several suites depend on these and were failing or skipping. Pass an explicit --ocapi-settings JSON granting the test client all methods on /* and /** so the suite no longer depends on DEFAULT_OCAPI_RESOURCES drift. Also removes the "invalid realm id" sandbox-lifecycle test — the b2c sandbox list --realm flag is a query filter (unknown realm yields an empty list and exit 0), so the assertion was checking behavior the command does not implement.
1 parent e361e09 commit e9579ef

2 files changed

Lines changed: 37 additions & 12 deletions

File tree

packages/b2c-cli/test/functional/e2e/hooks.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,47 @@ export const mochaHooks = {
4343

4444
const realm = process.env.TEST_REALM!;
4545
const shortCode = process.env.SFCC_SHORTCODE!;
46+
const clientId = process.env.SFCC_CLIENT_ID!;
47+
48+
// Catch-all OCAPI permissions for the test sandbox so e2e suites exercising
49+
// arbitrary endpoints (sites, job_execution_search, …) don't depend on the
50+
// built-in DEFAULT_OCAPI_RESOURCES list staying in sync with new tests.
51+
const ocapiSettings = JSON.stringify([
52+
{
53+
client_id: clientId,
54+
resources: [
55+
{
56+
resource_id: '/**',
57+
methods: ['get', 'post', 'put', 'patch', 'delete'],
58+
read_attributes: '(**)',
59+
write_attributes: '(**)',
60+
},
61+
{
62+
resource_id: '/*',
63+
methods: ['get', 'post', 'put', 'patch', 'delete'],
64+
read_attributes: '(**)',
65+
write_attributes: '(**)',
66+
},
67+
],
68+
},
69+
]);
4670

4771
try {
4872
// Create sandbox with long TTL (24 hours to cover all tests) + retry for transient errors
4973
const result = await runCLIWithRetry(
50-
['ods', 'create', '--realm', realm, '--ttl', '24', '--wait', '--set-permissions', '--json'],
74+
[
75+
'ods',
76+
'create',
77+
'--realm',
78+
realm,
79+
'--ttl',
80+
'24',
81+
'--wait',
82+
'--set-permissions',
83+
'--ocapi-settings',
84+
ocapiSettings,
85+
'--json',
86+
],
5187
{
5288
timeout: TIMEOUTS.ODS_OPERATION,
5389
maxRetries: 3,

packages/b2c-cli/test/functional/e2e/sandbox-lifecycle.test.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -417,17 +417,6 @@ describe('Sandbox Lifecycle E2E Tests', function () {
417417

418418
describe('Additional Test Cases', function () {
419419
describe('Error Handling', function () {
420-
it('should fail with a clear error for an invalid realm id', async function () {
421-
const result = await runCLI(['sandbox', 'list', '--realm', 'invalid-realm-xyz', '--json']);
422-
423-
expect(result.exitCode, 'invalid realm should produce a non-zero exit').to.equal(1);
424-
425-
const errorText = String(result.stderr || result.stdout || '');
426-
expect(errorText, 'invalid realm should surface a recognizable error message').to.match(
427-
/Failed to fetch sandboxes|invalid|realm/i,
428-
);
429-
});
430-
431420
it('should handle missing sandbox ID gracefully', async function () {
432421
const result = await runCLI(['sandbox', 'get', 'non-existent-sandbox-id', '--json']);
433422

0 commit comments

Comments
 (0)