Skip to content

Commit

Permalink
feat: evaluate if license is native kafka
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdiw committed Dec 16, 2024
1 parent e811553 commit 849430e
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,31 @@ describe('GioLicenseService', () => {
req.flush(oemLicense);
});

it('should check if license is native kafka', done => {
const oemLicense: License = {
tier: '',
packs: ['not-native-kafka'],
features: [],
};

gioLicenseService
.isNativeKafka$()
.pipe(
tap(isNativeKafka => {
expect(isNativeKafka).toEqual(false);
done();
}),
)
.subscribe();

const req = httpTestingController.expectOne({
method: 'GET',
url: `https://url.test:3000/license`,
});

req.flush(oemLicense);
});

// Need a workaround to be able to use both it.each and done callback https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34617#issuecomment-497760008
// eslint-disable-next-line @typescript-eslint/no-explicit-any
it.each<any>([
Expand Down Expand Up @@ -473,4 +498,50 @@ describe('GioLicenseService', () => {
req.flush(oemLicense);
});
});

describe('With Native Kafka license', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, MatDialogModule],
providers: [
{
provide: 'LicenseConfiguration',
useValue: OEM_LICENSE_CONFIGURATION_TESTING,
},
],
});

httpTestingController = TestBed.inject(HttpTestingController);
gioLicenseService = TestBed.inject<GioLicenseService>(GioLicenseService);
});

afterEach(() => {
httpTestingController.verify();
});

it('should check if license is native kafka', done => {
const nativeKafkaLicense: License = {
tier: '',
packs: ['native-kafka'],
features: [],
};

gioLicenseService
.isNativeKafka$()
.pipe(
tap(isNativeKafka => {
expect(isNativeKafka).toEqual(true);
done();
}),
)
.subscribe();

const req = httpTestingController.expectOne({
method: 'GET',
url: `https://oem.test:3000/license`,
});

req.flush(nativeKafkaLicense);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ export class GioLicenseService {
return this.getLicense$().pipe(map(license => license !== null && license.features.includes('oem-customization')));
}

public isNativeKafka$(): Observable<boolean> {
return this.getLicense$().pipe(map(license => license !== null && license.packs.includes('native-kafka')));
}

public openDialog(licenseOptions: LicenseOptions, event?: Event) {
event?.stopPropagation();
event?.preventDefault();
Expand Down

0 comments on commit 849430e

Please sign in to comment.