Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codefresh-io/authenticated-entity

Package Overview
Dependencies
Maintainers
32
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codefresh-io/authenticated-entity - npm Package Compare versions

Comparing version 2.14.2 to 2.14.3

22

lib/tests/User.unit.spec.js

@@ -19,3 +19,3 @@ 'use strict';

function fakeUserData() {
function fakeUserData(systemAdmin = false) {
return {

@@ -25,2 +25,3 @@ type: 'user',

userName: 'fake-userName',
roles: systemAdmin ? ['User', 'Admin'] : ['User'],
account: [

@@ -68,4 +69,4 @@ {

}
const encodedFakeUser = 'eyJ0eXBlIjoidXNlciIsIm5hbWUiOiJmYWtlLXVzZXJOYW1lIiwiX2lkIjoiZmFrZS11c2VyLWlkLTEiLCJhY2NvdW50cyI6W3sibmFtZSI6ImZha2UtYWNjb3VudC1uYW1lLTEiLCJpZCI6ImZha2UtYWNjb3VudElkLTEiLCJfaWQiOiJmYWtlLWFjY291bnRJZC0xIiwiaXNBZG1pbiI6dHJ1ZSwiYWRtaW5UZWFtIjoiMTIzNCIsInRlYW1zIjpbImZha2UtdGVhbS1pZC0yIiwiZmFrZS10ZWFtLWlkLTEiXSwicGF5bWVudFBsYW4iOiJmYWtlLWFjY291bnQtcGxhbi0xIiwic3VwcG9ydFBsYW4iOiJmYWtlLXN1cHBvcnQtcGxhbi0xIiwidHlwZSI6ImVudGVycHJpc2UiLCJ0cmlhbCI6ImZha2UtdHJpYWwiLCJzZWdtZW50IjoiZmFrZS1zZWdtZW50IiwicGlwZWxpbmVDb25maWciOnsiZmFrZS1jb25maWctMSI6dHJ1ZSwiZmFrZS1jb25maWctMiI6dHJ1ZX0sIkNGQ1JTdGF0ZSI6eyJlbmFibGVkIjpmYWxzZX0sInNoYXJlZENvbmZpZ1JlcG8iOiIifSx7Im5hbWUiOiJmYWtlLWFjY291bnQtbmFtZS0yIiwiaWQiOiJmYWtlLWFjY291bnRJZC0yIiwiX2lkIjoiZmFrZS1hY2NvdW50SWQtMiIsImlzQWRtaW4iOmZhbHNlLCJhZG1pblRlYW0iOiIxMjM0NSIsInRlYW1zIjpbImZha2UtdGVhbS1pZC0zIiwiZmFrZS10ZWFtLWlkLTQiXSwicGF5bWVudFBsYW4iOiJmYWtlLWFjY291bnQtcGxhbi0yIiwic3VwcG9ydFBsYW4iOiJmYWtlLXN1cHBvcnQtcGxhbi0yIiwidHlwZSI6ImVudGVycHJpc2UiLCJ0cmlhbCI6ImZha2UtdHJpYWwiLCJzZWdtZW50IjoiZmFrZS1zZWdtZW50IiwicGlwZWxpbmVDb25maWciOnsiZmFrZS1jb25maWctMSI6dHJ1ZSwiZmFrZS1jb25maWctMiI6dHJ1ZX0sIkNGQ1JTdGF0ZSI6eyJlbmFibGVkIjpmYWxzZX0sInNoYXJlZENvbmZpZ1JlcG8iOiIifV19';
const generatedHashFakeUser = 'd227388d3d9d1f0f862b725056defee5ed25e7a4d2a1aedd879385093e14b148';
const encodedFakeUser = 'eyJ0eXBlIjoidXNlciIsIm5hbWUiOiJmYWtlLXVzZXJOYW1lIiwiX2lkIjoiZmFrZS11c2VyLWlkLTEiLCJhY2NvdW50cyI6W3sibmFtZSI6ImZha2UtYWNjb3VudC1uYW1lLTEiLCJpZCI6ImZha2UtYWNjb3VudElkLTEiLCJfaWQiOiJmYWtlLWFjY291bnRJZC0xIiwiaXNBZG1pbiI6dHJ1ZSwiYWRtaW5UZWFtIjoiMTIzNCIsInRlYW1zIjpbImZha2UtdGVhbS1pZC0yIiwiZmFrZS10ZWFtLWlkLTEiXSwicGF5bWVudFBsYW4iOiJmYWtlLWFjY291bnQtcGxhbi0xIiwic3VwcG9ydFBsYW4iOiJmYWtlLXN1cHBvcnQtcGxhbi0xIiwidHlwZSI6ImVudGVycHJpc2UiLCJ0cmlhbCI6ImZha2UtdHJpYWwiLCJzZWdtZW50IjoiZmFrZS1zZWdtZW50IiwicGlwZWxpbmVDb25maWciOnsiZmFrZS1jb25maWctMSI6dHJ1ZSwiZmFrZS1jb25maWctMiI6dHJ1ZX0sIkNGQ1JTdGF0ZSI6eyJlbmFibGVkIjpmYWxzZX0sInNoYXJlZENvbmZpZ1JlcG8iOiIifSx7Im5hbWUiOiJmYWtlLWFjY291bnQtbmFtZS0yIiwiaWQiOiJmYWtlLWFjY291bnRJZC0yIiwiX2lkIjoiZmFrZS1hY2NvdW50SWQtMiIsImlzQWRtaW4iOmZhbHNlLCJhZG1pblRlYW0iOiIxMjM0NSIsInRlYW1zIjpbImZha2UtdGVhbS1pZC0zIiwiZmFrZS10ZWFtLWlkLTQiXSwicGF5bWVudFBsYW4iOiJmYWtlLWFjY291bnQtcGxhbi0yIiwic3VwcG9ydFBsYW4iOiJmYWtlLXN1cHBvcnQtcGxhbi0yIiwidHlwZSI6ImVudGVycHJpc2UiLCJ0cmlhbCI6ImZha2UtdHJpYWwiLCJzZWdtZW50IjoiZmFrZS1zZWdtZW50IiwicGlwZWxpbmVDb25maWciOnsiZmFrZS1jb25maWctMSI6dHJ1ZSwiZmFrZS1jb25maWctMiI6dHJ1ZX0sIkNGQ1JTdGF0ZSI6eyJlbmFibGVkIjpmYWxzZX0sInNoYXJlZENvbmZpZ1JlcG8iOiIifV0sImlzU3lzdGVtQWRtaW4iOmZhbHNlfQ==';
const generatedHashFakeUser = 'a53f1869706d2b85019f54f0653d19a2449b44c0a0a589213e8efe732dca0997';

@@ -119,2 +120,3 @@ const jsonValidUser = {

],
'isSystemAdmin': false,
'name': 'fake-userName'

@@ -311,3 +313,3 @@ };

expect((User.constructFromUserEntity(fakeUserData())).toString())
.to.be.equal(`{"type":"user","name":"fake-userName","_id":"fake-user-id-1","accounts":[{"name":"fake-account-name-1","id":"fake-accountId-1","_id":"fake-accountId-1","isAdmin":true,"adminTeam":"1234","teams":["fake-team-id-2","fake-team-id-1"],"paymentPlan":"fake-account-plan-1","supportPlan":"fake-support-plan-1","type":"enterprise","trial":"fake-trial","segment":"fake-segment","pipelineConfig":{"fake-config-1":true,"fake-config-2":true},"CFCRState":{"enabled":false},"sharedConfigRepo":""},{"name":"fake-account-name-2","id":"fake-accountId-2","_id":"fake-accountId-2","isAdmin":false,"adminTeam":"12345","teams":["fake-team-id-3","fake-team-id-4"],"paymentPlan":"fake-account-plan-2","supportPlan":"fake-support-plan-2","type":"enterprise","trial":"fake-trial","segment":"fake-segment","pipelineConfig":{"fake-config-1":true,"fake-config-2":true},"CFCRState":{"enabled":false},"sharedConfigRepo":""}]}`);
.to.be.equal(`{"type":"user","name":"fake-userName","_id":"fake-user-id-1","accounts":[{"name":"fake-account-name-1","id":"fake-accountId-1","_id":"fake-accountId-1","isAdmin":true,"adminTeam":"1234","teams":["fake-team-id-2","fake-team-id-1"],"paymentPlan":"fake-account-plan-1","supportPlan":"fake-support-plan-1","type":"enterprise","trial":"fake-trial","segment":"fake-segment","pipelineConfig":{"fake-config-1":true,"fake-config-2":true},"CFCRState":{"enabled":false},"sharedConfigRepo":""},{"name":"fake-account-name-2","id":"fake-accountId-2","_id":"fake-accountId-2","isAdmin":false,"adminTeam":"12345","teams":["fake-team-id-3","fake-team-id-4"],"paymentPlan":"fake-account-plan-2","supportPlan":"fake-support-plan-2","type":"enterprise","trial":"fake-trial","segment":"fake-segment","pipelineConfig":{"fake-config-1":true,"fake-config-2":true},"CFCRState":{"enabled":false},"sharedConfigRepo":""}],"isSystemAdmin":false}`);
});

@@ -351,2 +353,14 @@

describe('is system admin', () => {
it('should be system admin', () => {
const user = User.constructFromUserEntity(fakeUserData(true));
expect(user.isSystemAdmin()).to.be.true;
});
it('should not be system admin', () => {
const user = User.constructFromUserEntity(fakeUserData());
expect(user.isSystemAdmin()).to.be.false;
});
});
describe('Active account', () => {

@@ -353,0 +367,0 @@ it('should set active account when constructing entity from user model', () => {

@@ -40,3 +40,4 @@ const _ = require('lodash');

_id: userId,
accounts: user.account.map(account => this.extractAccountData(account, userId))
accounts: user.account.map(account => this.extractAccountData(account, userId)),
isSystemAdmin: (user.roles || []).includes('Admin'),
};

@@ -137,2 +138,6 @@

isSystemAdmin() {
return this._entity.isSystemAdmin;
}
get id() { // alias for consistency with execution-context entity

@@ -139,0 +144,0 @@ return this.getUserId();

4

package.json
{
"name": "@codefresh-io/authenticated-entity",
"version": "2.14.2",
"version": "2.14.3",
"description": "",

@@ -49,2 +49,2 @@ "main": "index.js",

}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc