import { describe, it, expect } from 'vitest';
import { computeEffectiveSecureCookie, shouldWarnDoubleTls } from './server.js';

describe('computeEffectiveSecureCookie', () => {
  it('is true when secure_cookie is on (proxy mode)', () => {
    expect(computeEffectiveSecureCookie(true, false)).toBe(true);
  });
  it('is true when native TLS is on even if secure_cookie is off', () => {
    expect(computeEffectiveSecureCookie(false, true)).toBe(true);
  });
  it('is false when neither', () => {
    expect(computeEffectiveSecureCookie(false, false)).toBe(false);
  });
});

describe('shouldWarnDoubleTls', () => {
  it('warns when native TLS and secure_cookie (proxy signal) are both on', () => {
    expect(shouldWarnDoubleTls(true, true)).toBe(true);
  });
  it('does not warn for a plain native-TLS install (secure_cookie off)', () => {
    expect(shouldWarnDoubleTls(true, false)).toBe(false);
  });
  it('does not warn when TLS is disabled', () => {
    expect(shouldWarnDoubleTls(false, true)).toBe(false);
  });
});
