import { isLoopbackAddress, validateRuntimeSecret } from '../../src/comm/runtime-secret';

describe('runtime-secret', () => {
  it('accepts loopback ipv4/ipv6 addresses', () => {
    expect(isLoopbackAddress('127.0.0.1')).toBe(true);
    expect(isLoopbackAddress('::1')).toBe(true);
    expect(isLoopbackAddress('::ffff:127.0.0.1')).toBe(true);
    expect(isLoopbackAddress('192.168.1.20')).toBe(false);
  });

  it('validates exact tray secret', () => {
    expect(validateRuntimeSecret('neta-secret', 'neta-secret')).toBe(true);
    expect(validateRuntimeSecret('neta-secret', 'wrong-secret')).toBe(false);
  });
});
