Skip to content

Commit 6977f1f

Browse files
committed
test: slightly improve some tests
1 parent bae730a commit 6977f1f

3 files changed

Lines changed: 26 additions & 16 deletions

File tree

src/plugins/customer-portal/index.e2e-spec.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,15 @@ describe('CustomerPortal', () => {
120120
it('should cleanup', async () => {
121121
const conn = global.bf.org.getConnection();
122122
await conn.metadata.delete('Profile', ['Dummy']);
123-
const permSetUnassignCmd = child.spawnSync('sf', [
124-
'data',
125-
'delete',
126-
'record',
127-
'-s',
128-
'PermissionSetAssignment',
129-
'-w',
130-
'PermissionSet.Name=Customer_Portal_Admin',
131-
]);
132-
assert.deepStrictEqual(permSetUnassignCmd.status, 0, permSetUnassignCmd.output.toString());
123+
const result = await conn.query(
124+
"SELECT Id FROM PermissionSetAssignment WHERE PermissionSet.Name='Customer_Portal_Admin'",
125+
);
126+
if (result.records.length) {
127+
await conn.delete(
128+
'PermissionSetAssignment',
129+
result.records.map((rec) => rec.Id),
130+
);
131+
}
133132
await conn.metadata.delete('PermissionSet', ['Customer_Portal_Admin']);
134133
});
135134
});

src/plugins/security/certificate-and-key-management/index.e2e-spec.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ describe(CertificateAndKeyManagement.name, function () {
1111
pluginCertificateManagement = new CertificateAndKeyManagement(global.bf);
1212
});
1313

14-
const configGeneratedCert = {
14+
const configCreatedCert = {
1515
certificates: [
1616
{
17-
name: 'identity_provider',
18-
label: 'identity_provider',
17+
name: 'foo',
18+
label: 'foo',
1919
},
2020
],
2121
};
@@ -35,11 +35,11 @@ describe(CertificateAndKeyManagement.name, function () {
3535
assert.deepStrictEqual(sourceDeployCmd.status, 0, sourceDeployCmd.output.toString());
3636
});
3737
it('should create a self-signed certificate', async () => {
38-
await pluginCertificateManagement.apply(configGeneratedCert);
38+
await pluginCertificateManagement.apply(configCreatedCert);
3939
});
4040
it('should not do anything if self-signed certificate is already available', async () => {
4141
// explictly pass definition to retrieve
42-
const res = await pluginCertificateManagement.run(configGeneratedCert);
42+
const res = await pluginCertificateManagement.run(configCreatedCert);
4343
assert.deepStrictEqual(res, { message: 'no action necessary' });
4444
});
4545
it('should import a cert from a keystore', async () => {
@@ -49,9 +49,15 @@ describe(CertificateAndKeyManagement.name, function () {
4949
const res = await pluginCertificateManagement.run(configImportFromKeystore);
5050
assert.deepStrictEqual(res, { message: 'no action necessary' });
5151
});
52+
it('should disable Identity Provider', async () => {
53+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
54+
const dir = resolve(join(__dirname, 'sfdx-source', 'disable-identity-provider'));
55+
const sourceDeployCmd = spawnSync('sf', ['project', 'deploy', 'start', '-d', dir, '--json']);
56+
assert.deepStrictEqual(sourceDeployCmd.status, 0, sourceDeployCmd.output.toString());
57+
});
5258
it('should delete certificates using Metadata API', async () => {
5359
const org = await Org.create({});
5460
const conn = org.getConnection();
55-
await conn.metadata.delete('Certificate', ['identity_provider', 'Dummy']);
61+
await conn.metadata.delete('Certificate', ['identity_provider', 'foo', 'Dummy']);
5662
});
5763
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<IdentityProviderSettings xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<certificateName>identity_provider</certificateName>
4+
<enableIdentityProvider>false</enableIdentityProvider>
5+
</IdentityProviderSettings>

0 commit comments

Comments
 (0)