Skip to content

Commit

Permalink
Merge pull request #359 from atomicsamurai/main
Browse files Browse the repository at this point in the history
Saml export dependency improvements
  • Loading branch information
atomicsamurai authored Jan 8, 2024
2 parents 611ecd8 + bbff85f commit b0254e4
Show file tree
Hide file tree
Showing 17 changed files with 9,209 additions and 480 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added tests for Saml export with and without deps

### Fixed

- Saml metadata is no more considered a dependency and will always be exportd

## [2.0.0-59] - 2024-01-05

## [2.0.0-58] - 2024-01-02
Expand Down
74 changes: 64 additions & 10 deletions src/ops/Saml2Ops.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* To record and update snapshots, you must perform 3 steps in order:
*
*
* 1. Record API responses
*
* This step breaks down into 5 phases:
Expand All @@ -18,13 +18,13 @@
* override all the connection state variables required to connect to the
* env to record from and also indicate the phase:
*
* FRODO_DEBUG=1 FRODO_RECORD_PHASE=1 FRODO_HOST=frodo-dev npm run test:record Saml2Ops
* FRODO_DEBUG=1 FRODO_RECORD_PHASE=2 FRODO_HOST=frodo-dev npm run test:record Saml2Ops
* FRODO_DEBUG=1 FRODO_RECORD_PHASE=1 npm run test:record Saml2Ops
* FRODO_DEBUG=1 FRODO_RECORD_PHASE=2 npm run test:record Saml2Ops
*
* THESE TESTS ARE DESTRUCTIVE!!! DO NOT RUN AGAINST AN ENV WITH ACTIVE CONFIGURATION!!!
*
* FRODO_DEBUG=1 FRODO_RECORD_PHASE=3 FRODO_HOST=frodo-dev npm run test:record Saml2Ops
* FRODO_DEBUG=1 FRODO_RECORD_PHASE=4 FRODO_HOST=frodo-dev npm run test:record Saml2Ops
* FRODO_DEBUG=1 FRODO_RECORD_PHASE=3 npm run test:record Saml2Ops
* FRODO_DEBUG=1 FRODO_RECORD_PHASE=4 npm run test:record Saml2Ops
*
* The above command assumes that you have a connection profile for
* 'frodo-dev' on your development machine.
Expand Down Expand Up @@ -56,7 +56,6 @@ import {
} from '../test/mocks/ForgeRockApiMockEngine';
import { encodeBase64Url } from '../utils/Base64Utils';
import { autoSetupPolly, filterRecording } from '../utils/AutoSetupPolly';

const ctx = autoSetupPolly();

state.setDeploymentType(Constants.CLOUD_DEPLOYMENT_TYPE_KEY);
Expand Down Expand Up @@ -218,6 +217,7 @@ describe('Saml2Ops', () => {
beforeEach(async () => {
if (process.env.FRODO_POLLY_MODE === 'record') {
ctx.polly.server.any().on('beforePersist', (_req, recording) => {
// console.debug('filtering...');
filterRecording(recording);
});
}
Expand Down Expand Up @@ -362,34 +362,88 @@ describe('Saml2Ops', () => {
expect(Saml2Ops.exportSaml2Provider).toBeDefined();
});

test(`1: Export hosted provider '${provider1.entityId}'`, async () => {
test(`1: Export hosted SP w/o dependencies '${provider1.entityId}'`, async () => {
const response = await Saml2Ops.exportSaml2Provider({
entityId: provider1.entityId,
options: { deps: false },
state,
});
expect(response).toMatchSnapshot({
meta: expect.any(Object),
});
});

test(`2: Export hosted SP w/ dependencies '${provider1.entityId}'`, async () => {
const response = await Saml2Ops.exportSaml2Provider({
entityId: provider1.entityId,
options: { deps: true },
state,
});
expect(response).toMatchSnapshot({
meta: expect.any(Object),
});
});

test(`3: Export hosted IdP w/o dependencies '${provider3.entityId}'`, async () => {
const response = await Saml2Ops.exportSaml2Provider({
entityId: provider3.entityId,
options: { deps: false },
state,
});
expect(response).toMatchSnapshot({
meta: expect.any(Object),
});
});

test(`4: Export hosted IdP w/ dependencies '${provider3.entityId}'`, async () => {
const response = await Saml2Ops.exportSaml2Provider({
entityId: provider3.entityId,
options: { deps: true },
state,
});
expect(response).toMatchSnapshot({
meta: expect.any(Object),
});
});

test(`5: Export remote IdP '${provider4.entityId}'`, async () => {
const response = await Saml2Ops.exportSaml2Provider({
entityId: provider4.entityId,
options: { deps: false },
state,
});
expect(response).toMatchSnapshot({
meta: expect.any(Object),
});
});

test(`2: Export remote provider '${provider4.entityId}'`, async () => {
test(`6: Export remote SP '${provider2.entityId}'`, async () => {
const response = await Saml2Ops.exportSaml2Provider({
entityId: provider4.entityId,
options: { deps: false },
state,
});
expect(response).toMatchSnapshot({
meta: expect.any(Object),
});
});

});

describe('exportSaml2Providers()', () => {
test('0: Method is implemented', async () => {
expect(Saml2Ops.exportSaml2Providers).toBeDefined();
});

test('1: Export saml2 entity providers', async () => {
const response = await Saml2Ops.exportSaml2Providers({ state });
test('1: Export saml2 entity providers w/o dependencies', async () => {
const response = await Saml2Ops.exportSaml2Providers({ options: { deps: false },state });
expect(response).toMatchSnapshot({
meta: expect.any(Object),
});
});

test('1: Export saml2 entity providers w/ dependencies', async () => {
const response = await Saml2Ops.exportSaml2Providers({ options: { deps: true },state });
expect(response).toMatchSnapshot({
meta: expect.any(Object),
});
Expand Down
Loading

0 comments on commit b0254e4

Please sign in to comment.