Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Add a prefix in the name of the auto-generated config.json api keys #1514

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading