Skip to content

Commit

Permalink
Merge pull request #1514 from balena-io/fix-legacy-user-api-key-cleanup
Browse files Browse the repository at this point in the history
tests: Add a prefix in the name of the auto-generated config.json api keys
  • Loading branch information
flowzone-app[bot] authored Dec 17, 2024
2 parents bdcf6fd + 1f23281 commit 5dfe0d3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/integration/models/os.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
IS_BROWSER,
applicationRetrievalFields,
sdkOpts,
TEST_KEY_NAME_PREFIX,
} from '../setup';
import { timeSuite } from '../../util';
import type * as BalenaSdk from '../../..';
Expand Down Expand Up @@ -986,6 +987,7 @@ describe('OS model', function () {
ctx.application[prop],
{
version: DEFAULT_OS_VERSION,
provisioningKeyName: `${TEST_KEY_NAME_PREFIX}-download-config-by-prop-${prop}`,
},
);
expect(config).to.have.property('applicationId');
Expand All @@ -1002,6 +1004,8 @@ describe('OS model', function () {
it('should be rejected if the version is invalid', function () {
const promise = balena.models.os.getConfig(ctx.application.id, {
version: 'v1+foo',
// Use a name prefix to make cleaning up the api key easier
provisioningKeyName: `${TEST_KEY_NAME_PREFIX}-download-config-rejected-lte-1-2-0`,
});
return expect(promise).to.be.rejected.then((error) => {
expect(error).to.have.property('message');
Expand All @@ -1014,6 +1018,8 @@ describe('OS model', function () {
it('should be rejected if the version is <= 1.2.0', function () {
const promise = balena.models.os.getConfig(ctx.application.id, {
version: '1.2.0',
// Use a name prefix to make cleaning up the api key easier
provisioningKeyName: `${TEST_KEY_NAME_PREFIX}-download-config-rejected-lte-1-2-0`,
});
return expect(promise).to.be.rejected.then((error) => {
expect(error).to.have.property('message');
Expand All @@ -1033,6 +1039,8 @@ describe('OS model', function () {
gateway: '5.6.7.8',
netmask: '9.10.11.12',
version: '1.26.1',
// Use a name prefix to make cleaning up the api key easier
provisioningKeyName: `${TEST_KEY_NAME_PREFIX}-download-config-1-26-1`,
};
return balena.models.os
.getConfig(ctx.application.id, configOptions)
Expand Down Expand Up @@ -1063,6 +1071,8 @@ describe('OS model', function () {
gateway: '5.6.7.8',
netmask: '9.10.11.12',
version: '2.0.8+rev1.prod',
// Use a name prefix to make cleaning up the api key easier
provisioningKeyName: `${TEST_KEY_NAME_PREFIX}-download-config-2-0-8-rev1`,
};
return balena.models.os
.getConfig(ctx.application.id, configOptions)
Expand All @@ -1079,7 +1089,7 @@ describe('OS model', function () {
});

it('should be able to configure v2 image with a provisioning key name', async function () {
const provisioningKeyName = `provision-key-${Date.now()}`;
const provisioningKeyName = `${TEST_KEY_NAME_PREFIX}-provision-key-v2-${Date.now()}`;
const configOptions = {
appUpdatePollInterval: 72,
network: 'wifi' as const,
Expand Down Expand Up @@ -1121,6 +1131,7 @@ describe('OS model', function () {
gateway: '5.6.7.8',
netmask: '9.10.11.12',
version: '2.11.8+rev1.prod',
provisioningKeyName: `${TEST_KEY_NAME_PREFIX}-download-config-with-expiry-date`,
provisioningKeyExpiryDate,
};

Expand All @@ -1145,6 +1156,7 @@ describe('OS model', function () {
it('should be rejected if the application id does not exist', function () {
const promise = balena.models.os.getConfig(999999, {
version: DEFAULT_OS_VERSION,
provisioningKeyName: `${TEST_KEY_NAME_PREFIX}-download-config-application-id-not-exists`,
});
return expect(promise).to.be.rejectedWith(
'Application not found: 999999',
Expand All @@ -1154,6 +1166,7 @@ describe('OS model', function () {
it('should be rejected if the application name does not exist', function () {
const promise = balena.models.os.getConfig('foobarbaz', {
version: DEFAULT_OS_VERSION,
provisioningKeyName: `${TEST_KEY_NAME_PREFIX}-download-config-application-name-not-exists`,
});
return expect(promise).to.be.rejectedWith(
'Application not found: foobarbaz',
Expand Down

0 comments on commit 5dfe0d3

Please sign in to comment.