snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
import { expect } from 'chai';
|
||||
|
||||
import {
|
||||
normalizers,
|
||||
fromTemplate,
|
||||
renameInvalidProperties,
|
||||
getNestedValue,
|
||||
getRegexpMatch,
|
||||
} from '../../../../../../server/lib/auth-providers/custom-oauth/transform_helpers';
|
||||
|
||||
const data = {
|
||||
'id': '123456',
|
||||
'invalid.property': true,
|
||||
'name': 'foo',
|
||||
'email': 'foo@bar.com',
|
||||
'nested': {
|
||||
'value': 'baz',
|
||||
'another.invalid.prop': true,
|
||||
},
|
||||
'list': [
|
||||
{
|
||||
'invalid.property': 'in-array',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe('fromTemplate', () => {
|
||||
const normalizedData = Object.values(normalizers).reduce((normalizedData, normalizer) => {
|
||||
const result = { ...normalizedData };
|
||||
normalizer({ ...result });
|
||||
|
||||
return result;
|
||||
}, data);
|
||||
|
||||
it('returns match from regexp on top-level properties', () => {
|
||||
const template = '{{/^foo@bar.(.+)/::email}}';
|
||||
const expected = 'com';
|
||||
const result = fromTemplate(template, normalizedData);
|
||||
expect(result).to.equal(expected);
|
||||
});
|
||||
|
||||
it('returns match from regexp on nested properties', () => {
|
||||
const template = '{{/^ba(.+)/::nested.value}}';
|
||||
const expected = 'z';
|
||||
const result = fromTemplate(template, normalizedData);
|
||||
expect(result).to.equal(expected);
|
||||
});
|
||||
|
||||
it('returns value from nested prop with plain syntax', () => {
|
||||
const template = 'nested.value';
|
||||
const expected = normalizedData.nested.value;
|
||||
const result = fromTemplate(template, normalizedData);
|
||||
expect(result).to.equal(expected);
|
||||
});
|
||||
|
||||
it('returns value from nested prop with template syntax', () => {
|
||||
const template = '{{nested.value}}';
|
||||
const expected = normalizedData.nested.value;
|
||||
const result = fromTemplate(template, normalizedData);
|
||||
expect(result).to.equal(expected);
|
||||
});
|
||||
|
||||
it('returns composed value from nested prop with template syntax', () => {
|
||||
const template = '{{name}}.{{nested.value}}';
|
||||
const expected = `${normalizedData.name}.${normalizedData.nested.value}`;
|
||||
const result = fromTemplate(template, normalizedData);
|
||||
|
||||
expect(result).to.equal(expected);
|
||||
});
|
||||
|
||||
it('returns composed string from multiple template chunks with static parts', () => {
|
||||
const template = 'composed-{{name}}-at-{{nested.value}}-dot-{{/^foo@bar.(.+)/::email}}-from-template';
|
||||
const expected = 'composed-foo-at-baz-dot-com-from-template';
|
||||
const result = fromTemplate(template, normalizedData);
|
||||
expect(result).to.equal(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getRegexpMatch', () => {
|
||||
it('returns nested value when formula is not in the regex::field form', () => {
|
||||
const formula = 'nested.value';
|
||||
expect(getRegexpMatch(formula, data)).to.equal(data.nested.value);
|
||||
});
|
||||
|
||||
it("returns undefined when regex doesn't match", () => {
|
||||
const formula = '/^foo@baz(.+)/::email';
|
||||
expect(getRegexpMatch(formula, data)).to.be.undefined;
|
||||
});
|
||||
|
||||
it("throws when regex isn't valid", () => {
|
||||
const formula = '/+/::email';
|
||||
expect(() => getRegexpMatch(formula, data)).to.throw();
|
||||
});
|
||||
});
|
||||
|
||||
describe('renameInvalidProperties', () => {
|
||||
it('replaces . chars in field names with _', () => {
|
||||
const result = renameInvalidProperties(data);
|
||||
|
||||
expect(result['invalid.property']).to.be.undefined;
|
||||
expect(result.invalid_property).to.equal(data['invalid.property']);
|
||||
|
||||
expect(result.nested['invalid.property']).to.be.undefined;
|
||||
expect(result.nested.invalid_property).to.equal(data.nested['invalid.property']);
|
||||
|
||||
result.list.forEach((item, idx) => {
|
||||
expect(item['invalid.property']).to.be.undefined;
|
||||
expect(item.invalid_property).to.equal(data.list[idx]['invalid.property']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getNestedValue', () => {
|
||||
it("returns undefined when nested value doesn't exist", () => {
|
||||
expect(getNestedValue('nested.does.not.exist', data)).to.be.undefined;
|
||||
});
|
||||
|
||||
it('returns nested object property', () => {
|
||||
expect(getNestedValue('nested.value', data)).to.equal(data.nested.value);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user