Skip to content

fix: don't finish process if no org is found W-18885856 #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .git2gus/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"productTag": "a1aB00000004Bx8IAE",
"defaultBuild": "offcore.tooling.64"
"defaultBuild": "offcore.tooling.64",
"issueTypeLabels": {
"feature": "USER STORY",
"regression": "BUG P1",
"bug": "BUG P3"
}
}
6 changes: 0 additions & 6 deletions src/shared/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ export async function getAllAllowedOrgs(): Promise<SanitizedOrgAuthorization[]>
// Filter out orgs that are not in ORG_ALLOWLIST
const allowedOrgs = await filterAllowedOrgs(sanitizedOrgs, orgAllowList);

// If no orgs are found, stop the server
if (allowedOrgs.length === 0) {
console.error('No orgs found that match the allowed orgs configuration. Check MCP Server startup config.');
process.exit(1);
}

return allowedOrgs;
}

Expand Down
24 changes: 0 additions & 24 deletions test/unit/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('auth tests', () => {
const sandbox = sinon.createSandbox();
let configAggregatorCreateStub: sinon.SinonStub;
let configAggregatorGetInfoStub: sinon.SinonStub;
let processExitStub: sinon.SinonStub;

beforeEach(() => {
// Reset ConfigAggregator instance before each test
Expand All @@ -41,9 +40,6 @@ describe('auth tests', () => {
configAggregatorCreateStub = sandbox.stub(ConfigAggregator, 'create');
configAggregatorGetInfoStub = sandbox.stub();

// Stub process.exit to prevent tests from actually exiting
processExitStub = sandbox.stub(process, 'exit');

// Mock the ConfigAggregator instance
const mockAggregator = {
getInfo: configAggregatorGetInfoStub,
Expand Down Expand Up @@ -302,7 +298,6 @@ describe('auth tests', () => {

describe('getAllAllowedOrgs', () => {
let authInfoListStub: sinon.SinonStub;
let consoleErrorStub: sinon.SinonStub;

beforeEach(() => {
// Set up mock org data that will be used across all tests
Expand Down Expand Up @@ -335,7 +330,6 @@ describe('auth tests', () => {

authInfoListStub = sandbox.stub(AuthInfo, 'listAllAuthorizations');
authInfoListStub.resolves(mockOrgs);
consoleErrorStub = sandbox.stub(console, 'error');

// Set up default responses for config queries (empty configs)
// This reuses the existing configAggregatorGetInfoStub from the main describe block
Expand Down Expand Up @@ -363,24 +357,6 @@ describe('auth tests', () => {
configAggregatorGetInfoStub.withArgs(OrgConfigProperties.TARGET_DEV_HUB).returns(emptyDevHubConfig);
});

it('should exit on an empty org list', async () => {
authInfoListStub.resolves([]);

// @ts-expect-error Dynamic import with query string to control ORG_ALLOWLIST for testing
const authModule = (await import('../../src/shared/auth.js?orgs=NONEXISTENT_ORG')) as typeof AuthModuleType;
const { getAllAllowedOrgs } = authModule;

await getAllAllowedOrgs();

expect(authInfoListStub.calledOnce).to.be.true;
expect(processExitStub.calledWith(1)).to.be.true;
expect(
consoleErrorStub.calledWith(
'No orgs found that match the allowed orgs configuration. Check MCP Server startup config.'
)
).to.be.true;
});

it('should only return orgs that exists in allowlist', async () => {
// @ts-expect-error Dynamic import with query string to control ORG_ALLOWLIST for testing
const authModule = (await import('../../src/shared/[email protected]')) as typeof AuthModuleType;
Expand Down
Loading