Skip to content
Open
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
29 changes: 28 additions & 1 deletion src/scenarios/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Scenario,
ClientScenario,
ClientScenarioForAuthorizationServer,
ScenarioForResourceAuthorizationServer,
ScenarioSource,
SpecVersion,
DatedSpecVersion,
Expand Down Expand Up @@ -315,6 +316,21 @@ export const clientScenariosForAuthorizationServer = new Map<
])
);

// All scenarios for the EMA Resource Authorization Server (ISSUE-470)
const allScenariosListForResourceAuthorizationServer: ScenarioForResourceAuthorizationServer[] =
[];

// Scenarios map for the EMA Resource Authorization Server - built from list
export const resourceAuthorizationServerScenarios = new Map<
string,
ScenarioForResourceAuthorizationServer
>(
allScenariosListForResourceAuthorizationServer.map((scenario) => [
scenario.name,
scenario
])
);

// All client test scenarios (core + backcompat + extensions)
const scenariosList: Scenario[] = [
new InitializeScenario(),
Expand Down Expand Up @@ -418,6 +434,16 @@ export function listClientScenariosForAuthorizationServer(): string[] {
return Array.from(clientScenariosForAuthorizationServer.keys());
}

export function getScenarioForResourceAuthorizationServer(
name: string
): ScenarioForResourceAuthorizationServer | undefined {
return resourceAuthorizationServerScenarios.get(name);
}

export function listScenariosForResourceAuthorizationServer(): string[] {
return Array.from(resourceAuthorizationServerScenarios.keys());
}

// All client-testing scenarios that target the draft spec, derived from the
// declared `source.introducedIn` rather than a hand-maintained list (covers
// both the auth draft scenarios and the non-auth ones, e.g. SEP-2243/2575).
Expand Down Expand Up @@ -514,7 +540,8 @@ export function getScenarioSpecVersions(
const s =
scenarios.get(name) ??
clientScenarios.get(name) ??
clientScenariosForAuthorizationServer.get(name);
clientScenariosForAuthorizationServer.get(name) ??
resourceAuthorizationServerScenarios.get(name);
if (!s) return undefined;
if ('extensionId' in s.source) return ['extension'];
const result: ScenarioSpecTag[] = [];
Expand Down
67 changes: 66 additions & 1 deletion src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { z } from 'zod';
import {
getScenario,
getClientScenario,
getClientScenarioForAuthorizationServer
getClientScenarioForAuthorizationServer,
getScenarioForResourceAuthorizationServer
} from './scenarios';

// Client command options schema
Expand Down Expand Up @@ -78,6 +79,70 @@ export type AuthorizationServerOptions = z.infer<
typeof AuthorizationServerOptionsSchema
>;

// Resource authorization server (EMA / ID-JAG) command options schema.
//
// Settings a human tester provides to point a scenario at a *real* target
// Resource AS they have pre-provisioned. `url` is the only field every scenario
// needs (it discovers the token/introspection endpoints from the issuer's
// server metadata); each scenario validates the additional fields it requires
// and skips when they are absent, so the remaining fields are schema-optional.
export const ResourceAuthorizationServerOptionsSchema = z.object({
// [1] Issuer URL of the target Resource AS. The runner GETs its server
// metadata (well-known URL derived from the issuer) to learn the token and
// introspection endpoints. Required by every scenario.
url: z.string().url('Invalid resource authorization server URL'),
scenario: z
.string()
.min(1, 'Scenario cannot be empty')
.refine(
(scenario) =>
getScenarioForResourceAuthorizationServer(scenario) !== undefined,
{
error: (iss) => `Unknown scenario '${iss.input}'`
}
)
.optional(),
// [2] client_id of the MCP Client the tester registered with the Resource AS.
clientId: z.string().min(1, 'Client id cannot be empty').optional(),
// [3] Client secret for that MCP Client (client_secret_post authentication).
clientSecret: z.string().min(1, 'Client secret cannot be empty').optional(),
// [4] Issuer URL of an IdP AS the target Resource AS trusts (accepts ID-JAGs
// whose `iss` matches).
trustedIdpIssuer: z.string().url('Invalid trusted IdP issuer URL').optional(),
// [5] Issuer URL of an IdP AS the target Resource AS does not trust (rejects
// ID-JAGs whose `iss` matches).
untrustedIdpIssuer: z
.string()
.url('Invalid untrusted IdP issuer URL')
.optional(),
// [6] URL of an MCP Server the Resource AS trusts; used as the ID-JAG
// `resource`. Optional — only needed for scenarios exercising `resource`.
trustedMcpServer: z.string().url('Invalid trusted MCP server URL').optional(),
// [7] URL of an MCP Server the Resource AS does not trust; used as the ID-JAG
// `resource`. Optional — only needed for scenarios exercising `resource`.
untrustedMcpServer: z
.string()
.url('Invalid untrusted MCP server URL')
.optional(),
// [8] OAuth 2.0 scope the Resource AS recognises; used as the ID-JAG `scope`.
// Optional — only needed for scenarios exercising `scope`.
scope: z.string().min(1, 'Scope cannot be empty').optional(),
// [9] User id registered with the target Resource AS; the Resource AS is
// expected to place this value in the `sub` claim of the access token it
// issues for the linked IdP-registered user (see `idpSub`). Optional —
// only needed for scenarios exercising `sub`.
sub: z.string().min(1, 'Subject cannot be empty').optional(),
// [10] User id registered with the trusted IdP AS for that same person;
// used as the ID-JAG `sub` claim. The IdP and the Resource AS may assign the
// same human different ids, so this is intentionally distinct from `sub`
// above. Optional — only needed for scenarios exercising `sub`.
idpSub: z.string().min(1, 'Subject cannot be empty').optional()
});

export type ResourceAuthorizationServerOptions = z.infer<
typeof ResourceAuthorizationServerOptionsSchema
>;

// Interactive command options schema
export const InteractiveOptionsSchema = z.object({
scenario: z
Expand Down
15 changes: 14 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { RunContext } from './connection';
import type { ScenarioContext } from './mock-server';
import type { AuthorizationServerOptions } from './schemas';
import type {
AuthorizationServerOptions,
ResourceAuthorizationServerOptions
} from './schemas';

export type CheckStatus =
| 'SUCCESS'
Expand Down Expand Up @@ -159,3 +162,13 @@ export interface ClientScenarioForAuthorizationServer {
details: Record<string, unknown>
): Promise<ConformanceCheck[]>;
}

export interface ScenarioForResourceAuthorizationServer {
name: string;
description: string;
source: ScenarioSource;
run(
options: ResourceAuthorizationServerOptions,
details: Record<string, unknown>
): Promise<ConformanceCheck[]>;
}
Loading