Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
3cddda67
Commit
3cddda67
authored
9 months ago
by
Douglas Gubert
Committed by
Guilherme Gazzo
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
test: Copy new EE test license from CI to unit tests (#32711)
parent
8227d0e5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.github/workflows/ci-test-unit.yml
+4
-0
4 additions, 0 deletions
.github/workflows/ci-test-unit.yml
.github/workflows/ci.yml
+1
-0
1 addition, 0 deletions
.github/workflows/ci.yml
ee/packages/license/__tests__/setLicense.spec.ts
+24
-23
24 additions, 23 deletions
ee/packages/license/__tests__/setLicense.spec.ts
with
29 additions
and
23 deletions
.github/workflows/ci-test-unit.yml
+
4
−
0
View file @
3cddda67
...
...
@@ -6,6 +6,9 @@ on:
node-version
:
required
:
true
type
:
string
enterprise-license
:
required
:
false
type
:
string
secrets
:
CODECOV_TOKEN
:
required
:
false
...
...
@@ -13,6 +16,7 @@ on:
env
:
MONGO_URL
:
mongodb://localhost:27017/rocketchat?replicaSet=rs0&directConnection=true
TOOL_NODE_FLAGS
:
${{ vars.TOOL_NODE_FLAGS }}
ENTERPRISE_LICENSE
:
${{ inputs.enterprise-license }}
jobs
:
test
:
...
...
This diff is collapsed.
Click to expand it.
.github/workflows/ci.yml
+
1
−
0
View file @
3cddda67
...
...
@@ -301,6 +301,7 @@ jobs:
uses
:
./.github/workflows/ci-test-unit.yml
with
:
node-version
:
${{ needs.release-versions.outputs.node-version }}
enterprise-license
:
${{ needs.release-versions.outputs.enterprise-license }}
secrets
:
CODECOV_TOKEN
:
${{ secrets.CODECOV_TOKEN }}
...
...
This diff is collapsed.
Click to expand it.
ee/packages/license/__tests__/setLicense.spec.ts
+
24
−
23
View file @
3cddda67
...
...
@@ -10,7 +10,8 @@ import { MockedLicenseBuilder, getReadyLicenseManager } from './MockedLicenseBui
// Same license used on ci tasks so no I didnt leak it
const
VALID_LICENSE
=
'
WMa5i+/t/LZbYOj8u3XUkivRhWBtWO6ycUjaZoVAw2DxMfdyBIAa2gMMI4x7Z2BrTZIZhFEImfOxcXcgD0QbXHGBJaMI+eYG+eofnVWi2VA7RWbpvWTULgPFgyJ4UEFeCOzVjcBLTQbmMSam3u0RlekWJkfAO0KnmLtsaEYNNA2rz1U+CLI/CdNGfdqrBu5PZZbGkH0KEzyIZMaykOjzvX+C6vd7fRxh23HecwhkBbqE8eQsCBt2ad0qC4MoVXsDaSOmSzGW+aXjuXt/9zjvrLlsmWQTSlkrEHdNkdywm0UkGxqz3+CP99n0WggUBioUiChjMuNMoceWvDvmxYP9Ml2NpYU7SnfhjmMFyXOah8ofzv8w509Y7XODvQBz+iB4Co9YnF3vT96HDDQyAV5t4jATE+0t37EAXmwjTi3qqyP7DLGK/revl+mlcwJ5kS4zZBsm1E4519FkXQOZSyWRnPdjqvh4mCLqoispZ49wKvklDvjPxCSP9us6cVXLDg7NTJr/4pfxLPOkvv7qCgugDvlDx17bXpQFPSDxmpw66FLzvb5Id0dkWjOzrRYSXb0bFWoUQjtHFzmcpFkyVhOKrQ9zA9+Zm7vXmU9Y2l2dK79EloOuHMSYAqsPEag8GMW6vI/cT4iIjHGGDePKnD0HblvTEKzql11cfT/abf2IiaY=
'
;
process
.
env
.
ENTERPRISE_LICENSE
||
'
X/XumwIkgwQuld0alWKt37lVA90XjKOrfiMvMZ0/RtqsMtrdL9GoAk+4jXnaY1b2ePoG7XSzGhuxEDxFKIWJK3hIKGNTvrd980LgH5sM5+1T4P42ivSpd8UZi0bwjJkCFLIu9RozzYwslGG0IehMxe0S6VjcO0UYlUJtbMCBHuR2WmTAmO6YVU3ln+pZCbrPFaTPSS1RovhKaNCNkZwIx/CLWW8UTXUuFV/ML4PbKKVoa5nvvJwPeatgL7UCnlSD90lfCiiuikpzj/Y/JLkIL6velFbwNxsrxg9iRJ2k0sKheMMSmlTiGzSvZUm+na5WQq91aKGncih+DmaEZA7QGrjp4eoA0dqTk6OmItsy0fHmQhvZIOKNMeO7vNQiLbaSV6rqibrzu7WPpeIvsvL57T1h37USoCSB6+jDqkzdfoqIpz8BxTiJDj1d8xGPJFVrgxoqQqkj9qIP/gCaEz5DF39QFv5sovk4yK2O8fEQYod2d14V9yECYl4szZPMk1IBfCAC2w7czWGHHFonhL+CQGT403y5wmDmnsnjlCqMKF72odqfTPTI8XnCvJDriPMWohnQEAGtTTyciAhNokx/mjAVJ4NeZPcsbm4BjhvJvnjxx/BhYhBBTNWPaCSZzocfrGUj9Z+ZA7BEz+xAFQyGDx3xRzqIXfT0G7w8fvgYJMU=
'
;
describe
(
'
License set license procedures
'
,
()
=>
{
describe
(
'
Invalid formats
'
,
()
=>
{
...
...
@@ -36,11 +37,11 @@ describe('License set license procedures', () => {
it
(
'
should throw an error if the license is expired
'
,
async
()
=>
{
const
license
=
await
getReadyLicenseManager
();
const
mocked
=
await
new
MockedLicenseBuilder
();
const
mocked
=
new
MockedLicenseBuilder
();
const
token
=
await
mocked
.
withExpiredDate
().
sign
();
await
license
.
setLicense
(
token
);
await
expect
(
license
.
hasValidLicense
()).
toBe
(
false
);
expect
(
license
.
hasValidLicense
()).
toBe
(
false
);
});
describe
(
'
license that is not not started yet is applied
'
,
()
=>
{
...
...
@@ -51,19 +52,19 @@ describe('License set license procedures', () => {
const
token
=
await
mocked
.
withNotStartedDate
().
sign
();
await
license
.
setLicense
(
token
);
await
expect
(
license
.
hasValidLicense
()).
toBe
(
false
);
expect
(
license
.
hasValidLicense
()).
toBe
(
false
);
});
it
(
'
should be allowed to set the same license again if the license is not started yet
'
,
async
()
=>
{
const
license
=
await
getReadyLicenseManager
();
const
mocked
=
await
new
MockedLicenseBuilder
();
const
as
=
await
mocked
.
resetValidPeriods
().
withNotStartedDate
();
const
mocked
=
new
MockedLicenseBuilder
();
const
as
=
mocked
.
resetValidPeriods
().
withNotStartedDate
();
const
token
=
await
as
.
sign
();
await
license
.
setLicense
(
token
);
await
expect
(
license
.
hasValidLicense
()).
toBe
(
false
);
expect
(
license
.
hasValidLicense
()).
toBe
(
false
);
// 5 minutes in the future
...
...
@@ -78,7 +79,7 @@ describe('License set license procedures', () => {
jest
.
useRealTimers
();
await
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
});
});
});
...
...
@@ -94,10 +95,10 @@ describe('License set license procedures', () => {
const
license
=
await
getReadyLicenseManager
();
await
expect
(
license
.
setLicense
(
VALID_LICENSE
)).
resolves
.
toBe
(
true
);
await
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
await
expect
(
license
.
setLicense
(
'
invalid
'
)).
rejects
.
toThrow
(
InvalidLicenseError
);
await
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
});
describe
(
'
Pending cases
'
,
()
=>
{
...
...
@@ -114,14 +115,14 @@ describe('License set license procedures', () => {
await
expect
(
license
.
setLicense
(
VALID_LICENSE
)).
rejects
.
toThrow
(
NotReadyForValidation
);
await
expect
(
license
.
hasValidLicense
()).
toBe
(
false
);
expect
(
license
.
hasValidLicense
()).
toBe
(
false
);
});
it
(
'
should return a valid license if the license is ready for validation
'
,
async
()
=>
{
const
license
=
await
getReadyLicenseManager
();
await
expect
(
license
.
setLicense
(
VALID_LICENSE
)).
resolves
.
toBe
(
true
);
await
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
});
});
...
...
@@ -131,24 +132,24 @@ describe('License set license procedures', () => {
const
token
=
await
new
MockedLicenseBuilder
().
sign
();
await
expect
(
license
.
setLicense
(
token
)).
resolves
.
toBe
(
true
);
await
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
});
it
(
'
should accept new licenses
'
,
async
()
=>
{
const
license
=
await
getReadyLicenseManager
();
const
mocked
=
await
new
MockedLicenseBuilder
();
const
mocked
=
new
MockedLicenseBuilder
();
const
oldToken
=
await
mocked
.
sign
();
const
newToken
=
await
mocked
.
withGratedModules
([
'
livechat-enterprise
'
]).
sign
();
await
expect
(
license
.
setLicense
(
oldToken
)).
resolves
.
toBe
(
true
);
await
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
await
expect
(
license
.
hasModule
(
'
livechat-enterprise
'
)).
toBe
(
false
);
expect
(
license
.
hasModule
(
'
livechat-enterprise
'
)).
toBe
(
false
);
await
expect
(
license
.
setLicense
(
newToken
)).
resolves
.
toBe
(
true
);
await
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
await
expect
(
license
.
hasModule
(
'
livechat-enterprise
'
)).
toBe
(
true
);
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
expect
(
license
.
hasModule
(
'
livechat-enterprise
'
)).
toBe
(
true
);
});
it
(
'
should call a validated event after set a valid license
'
,
async
()
=>
{
...
...
@@ -156,7 +157,7 @@ describe('License set license procedures', () => {
const
validateCallback
=
jest
.
fn
();
license
.
onValidateLicense
(
validateCallback
);
await
expect
(
license
.
setLicense
(
VALID_LICENSE
)).
resolves
.
toBe
(
true
);
await
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
expect
(
license
.
hasValidLicense
()).
toBe
(
true
);
expect
(
validateCallback
).
toBeCalledTimes
(
1
);
});
...
...
@@ -166,7 +167,7 @@ describe('License set license procedures', () => {
const
invalidationCallback
=
jest
.
fn
();
const
licenseManager
=
await
getReadyLicenseManager
();
const
mocked
=
await
new
MockedLicenseBuilder
();
const
mocked
=
new
MockedLicenseBuilder
();
const
oldToken
=
await
mocked
.
withLimits
(
'
activeUsers
'
,
[
{
...
...
@@ -190,12 +191,12 @@ describe('License set license procedures', () => {
licenseManager
.
setLicenseLimitCounter
(
'
activeUsers
'
,
()
=>
5
);
await
expect
(
licenseManager
.
setLicense
(
oldToken
)).
resolves
.
toBe
(
true
);
await
expect
(
licenseManager
.
hasValidLicense
()).
toBe
(
true
);
expect
(
licenseManager
.
hasValidLicense
()).
toBe
(
true
);
await
expect
(
licenseManager
.
setLicense
(
newToken
)).
resolves
.
toBe
(
true
);
await
expect
(
licenseManager
.
hasValidLicense
()).
toBe
(
false
);
expect
(
licenseManager
.
hasValidLicense
()).
toBe
(
false
);
await
expect
(
invalidationCallback
).
toBeCalledTimes
(
1
);
expect
(
invalidationCallback
).
toBeCalledTimes
(
1
);
});
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment