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

regression: wrong app limits displayed on the UI #30840

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion ee/packages/license/src/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getModules } from './modules';
import { defaultLimits } from './validation/validateDefaultLimits';

export const getLicenseLimit = (license: ILicenseV3 | undefined, kind: LicenseLimitKind) => {
const limitList = license?.limits[kind] ?? defaultLimits[kind as keyof typeof defaultLimits];
const limitList = license ? license.limits[kind] : defaultLimits[kind as keyof typeof defaultLimits];

if (!limitList?.length) {
return -1;
Expand Down
27 changes: 27 additions & 0 deletions ee/packages/license/src/getLicenseLimit.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { LicenseImp } from '.';
import { MockedLicenseBuilder, getReadyLicenseManager } from '../__tests__/MockedLicenseBuilder';
import { getAppsConfig } from './deprecated';

describe('Marketplace Restrictions', () => {
it('should respect the default if there is no license applied', async () => {
const LicenseManager = new LicenseImp();

expect(getAppsConfig.call(LicenseManager)).toEqual({
maxPrivateApps: 3,
maxMarketplaceApps: 5,
});
});

it('should return unlimited if there is license but no limits', async () => {
const licenseManager = await getReadyLicenseManager();

const license = await new MockedLicenseBuilder();

await expect(licenseManager.setLicense(await license.sign())).resolves.toBe(true);

await expect(getAppsConfig.call(licenseManager)).toEqual({
maxPrivateApps: -1,
maxMarketplaceApps: -1,
});
});
});
43 changes: 43 additions & 0 deletions ee/packages/license/src/license.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { LicenseImp } from '.';
import { MockedLicenseBuilder, getReadyLicenseManager } from '../__tests__/MockedLicenseBuilder';

it('should not prevent if there is no license', async () => {
Expand Down Expand Up @@ -231,3 +232,45 @@ describe('Validate License Limits', () => {
});
});
});

describe('License.getInfo', () => {
describe('Marketplace Restrictions', () => {
it('should respect the default if there is no license applied', async () => {
const licenseManager = new LicenseImp();

expect(
(
await licenseManager.getInfo({
limits: true,
currentValues: false,
license: false,
})
).limits,
).toMatchObject({
privateApps: { max: 3 },
marketplaceApps: { max: 5 },
});
});

it('should return unlimited if there is license but no limits', async () => {
const licenseManager = await getReadyLicenseManager();

const license = await new MockedLicenseBuilder();

await expect(licenseManager.setLicense(await license.sign())).resolves.toBe(true);

await expect(
(
await licenseManager.getInfo({
limits: true,
currentValues: false,
license: false,
})
).limits,
).toMatchObject({
privateApps: { max: -1 },
marketplaceApps: { max: -1 },
});
});
});
});