Skip to content

Commit

Permalink
Merge pull request #17651 from ckeditor/update-dev-check
Browse files Browse the repository at this point in the history
Internal: Update the logic of the license check.
  • Loading branch information
arkflpc authored Dec 17, 2024
2 parents bb5273a + 49b8326 commit fd1d41e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
3 changes: 1 addition & 2 deletions docs/getting-started/licensing/license-key-and-activation.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ This key grants access to your subscription features. It does not consume editor

* **Features**: Grants access to subscription features.
* **Functionality**:
* Similar to the trial license, the editor is limited functionally, including session time and the number of changes allowed.
* Additionally, there are limitations on development domains. The editor can be used in the following domains: `localhost`, `*.test`, `*.localhost`, `*.local`, and IP addresses: `127.0.0.1`, `192.168.*.*`, `10.*.*.*`, `172.*.*.*`.
* Limitations on development domains apply on usage-based plans. The editor can be used in the following domains: `localhost`, `*.test`, `*.localhost`, `*.local`, and IP addresses: `127.0.0.1`, `192.168.*.*`, `10.*.*.*`, `172.*.*.*`.
* The editor will show a banner informing it was launched for development purposes.
* **Intended use**: Designed for development environments such as local work, continuous integration (CI), and end-to-end (E2E) tests.
* **Usage limitation**: Must not be used for production environments.
Expand Down
11 changes: 9 additions & 2 deletions packages/ckeditor5-core/src/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ export default abstract class Editor extends /* #__PURE__ */ ObservableMixin() {
return;
}

if ( [ 'evaluation', 'trial', 'development' ].includes( licensePayload.licenseType ) ) {
const licenseType: 'evaluation' | 'trial' | 'development' = licensePayload.licenseType;
if ( [ 'evaluation', 'trial' ].includes( licensePayload.licenseType ) ) {
const licenseType: 'evaluation' | 'trial' = licensePayload.licenseType;

console.info(
`You are using the ${ licenseType } version of CKEditor 5 with limited usage. ` +
Expand All @@ -542,6 +542,13 @@ export default abstract class Editor extends /* #__PURE__ */ ObservableMixin() {
} );
}

if ( licensePayload.licenseType === 'development' ) {
console.info(
'You are using the development version of CKEditor 5. ' +
'Make sure you will not use it in the production environment.'
);
}

if ( licensePayload.usageEndpoint ) {
editor.once<EditorReadyEvent>( 'ready', () => {
const request = {
Expand Down
14 changes: 7 additions & 7 deletions packages/ckeditor5-core/tests/editor/licensecheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ describe( 'Editor - license check', () => {

expect( editor.isReadOnly ).to.be.false;
sinon.assert.calledOnce( consoleInfoStub );
sinon.assert.calledWith( consoleInfoStub, 'You are using the development version of CKEditor 5 with ' +
'limited usage. Make sure you will not use it in the production environment.' );
sinon.assert.calledWith( consoleInfoStub, 'You are using the development version of CKEditor 5. ' +
'Make sure you will not use it in the production environment.' );
} );

it( 'should not block the editor if 10 minutes have not passed (development license)', () => {
Expand All @@ -466,7 +466,7 @@ describe( 'Editor - license check', () => {
dateNow.restore();
} );

it( 'should block editor after 10 minutes (development license)', () => {
it( 'should not block editor after 10 minutes (development license)', () => {
const { licenseKey, todayTimestamp } = generateKey( {
licenseType: 'development'
} );
Expand All @@ -480,13 +480,13 @@ describe( 'Editor - license check', () => {

sinon.clock.tick( 600100 );

sinon.assert.calledWithMatch( showErrorStub, 'developmentLimit' );
expect( editor.isReadOnly ).to.be.true;
sinon.assert.notCalled( showErrorStub );
expect( editor.isReadOnly ).to.be.false;

dateNow.restore();
} );

it( 'should clear timer on editor destroy', done => {
it( 'should not interact with timers', done => {
const { licenseKey, todayTimestamp } = generateKey( {
licenseType: 'development'
} );
Expand All @@ -497,7 +497,7 @@ describe( 'Editor - license check', () => {

editor.fire( 'ready' );
editor.on( 'destroy', () => {
sinon.assert.calledOnce( clearTimeoutSpy );
sinon.assert.notCalled( clearTimeoutSpy );
done();
} );

Expand Down

0 comments on commit fd1d41e

Please sign in to comment.