// {{ display_name }} MCP server — generated by mcpify. Do not hand-edit.

import { generateKeyPairSync } from 'node:crypto';

import { describe, expect, it } from 'vitest';

import { OAuth1Strategy } from '../../../src/auth/strategies/oauth1.js';

describe('OAuth1Strategy', () => {
  it('throws when consumerKey/privateKey are missing', async () => {
    const strategy = new OAuth1Strategy();
    await expect(strategy.authenticate({})).rejects.toThrow();
  });

  it('builds an RSA-SHA1-signed Authorization header for a request', async () => {
    const { privateKey } = generateKeyPairSync('rsa', { modulusLength: 2048 });
    const strategy = new OAuth1Strategy();
    const credentials = await strategy.authenticate({
      consumerKey: 'consumer',
      privateKey: privateKey.export({ type: 'pkcs1', format: 'pem' }).toString(),
    });

    const header = strategy.buildAuthorizationHeader(credentials, 'GET', 'https://example.com/widgets');

    expect(header).toMatch(/^OAuth /);
  });
});
