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

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

import { BasicAuthStrategy } from '../../../src/auth/strategies/basic.js';

describe('BasicAuthStrategy', () => {
  it('builds a base64 Authorization header from username/password', async () => {
    const strategy = new BasicAuthStrategy();
    const credentials = await strategy.authenticate({ username: 'alice', password: 'secret' });
    expect(credentials.authorizationHeader).toBe(`Basic ${Buffer.from('alice:secret').toString('base64')}`);
  });

  it('throws when credentials are missing', async () => {
    const strategy = new BasicAuthStrategy();
    await expect(strategy.authenticate({})).rejects.toThrow();
  });

  it('validateCredentials requires an authorizationHeader', () => {
    const strategy = new BasicAuthStrategy();
    expect(strategy.validateCredentials({ authorizationHeader: 'Basic xyz' })).toBe(true);
    expect(strategy.validateCredentials({})).toBe(false);
  });
});
