Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

2.0 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.

import { describe, expect, it } from "vitest";
import { requiresItarEntityCertification } from "./const";

describe("requiresItarEntityCertification", () => {
  it("exempts Carbon staff, who provision customer tenants but cannot bind them", () => {
    expect(requiresItarEntityCertification("[email protected]")).toBe(false);
    expect(requiresItarEntityCertification("[email protected]")).toBe(
      false
    );
  });

  it("normalizes case and padding, so the gate cannot be dodged by formatting", () => {
    expect(requiresItarEntityCertification("[email protected]")).toBe(false);
    expect(requiresItarEntityCertification("  [email protected]  ")).toBe(false);
  });

  it("requires the entity Rider from customer accounts", () => {
    expect(requiresItarEntityCertification("[email protected]")).toBe(true);
    expect(requiresItarEntityCertification("[email protected]")).toBe(
      true
    );
  });

  it("does not hand the exemption to addresses that merely contain a Carbon domain", () => {
    // The bypass decides who may sign on a customer's behalf, so near-misses
    // must all fall through to "required".
    expect(requiresItarEntityCertification("[email protected]")).toBe(
      true
    );
    expect(requiresItarEntityCertification("[email protected]")).toBe(
      true
    );
    expect(requiresItarEntityCertification("[email protected]")).toBe(true);
    expect(requiresItarEntityCertification("[email protected]")).toBe(
      true
    );
    expect(requiresItarEntityCertification("[email protected]")).toBe(
      true
    );
  });

  it("fails closed when the email is unknown", () => {
    expect(requiresItarEntityCertification(null)).toBe(true);
    expect(requiresItarEntityCertification(undefined)).toBe(true);
    expect(requiresItarEntityCertification("")).toBe(true);
  });
});