Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  reconnect-gating.test.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import { describe, expect, it } from "vitest";
import { type GatewayErrorInfo, isNonRecoverableAuthError } from "../../ui/src/ui/gateway.ts";
import { ConnectErrorDetailCodes } from "./protocol/connect-error-details.js";

function makeError(detailCode: string): GatewayErrorInfo {
  return { code: "connect_failed", message: "auth failed", details: { code: detailCode } };
}

describe("isNonRecoverableAuthError", () => {
  it("returns false for undefined error (normal disconnect)", () => {
    expect(isNonRecoverableAuthError(undefined)).toBe(false);
  });

  it("returns false for errors without detail codes (network issues)", () => {
    expect(isNonRecoverableAuthError({ code: "connect_failed", message: "timeout" })).toBe(false);
  });

  it("blocks reconnect for AUTH_TOKEN_MISSING (misconfigured client)", () => {
    expect(isNonRecoverableAuthError(makeError(ConnectErrorDetailCodes.AUTH_TOKEN_MISSING))).toBe(
      true,
    );
  });

  it("blocks reconnect for AUTH_BOOTSTRAP_TOKEN_INVALID", () => {
    expect(
      isNonRecoverableAuthError(makeError(ConnectErrorDetailCodes.AUTH_BOOTSTRAP_TOKEN_INVALID)),
    ).toBe(true);
  });

  it("blocks reconnect for AUTH_PASSWORD_MISSING", () => {
    expect(
      isNonRecoverableAuthError(makeError(ConnectErrorDetailCodes.AUTH_PASSWORD_MISSING)),
    ).toBe(true);
  });

  it("blocks reconnect for AUTH_PASSWORD_MISMATCH (wrong password won't self-correct)", () => {
    expect(
      isNonRecoverableAuthError(makeError(ConnectErrorDetailCodes.AUTH_PASSWORD_MISMATCH)),
    ).toBe(true);
  });

  it("blocks reconnect for AUTH_RATE_LIMITED (reconnecting burns more slots)", () => {
    expect(isNonRecoverableAuthError(makeError(ConnectErrorDetailCodes.AUTH_RATE_LIMITED))).toBe(
      true,
    );
  });

  it("blocks reconnect for PAIRING_REQUIRED", () => {
    expect(isNonRecoverableAuthError(makeError(ConnectErrorDetailCodes.PAIRING_REQUIRED))).toBe(
      true,
    );
  });

  it("allows reconnect for AUTH_TOKEN_MISMATCH (device-token fallback flow)", () => {
    // Browser client can queue a single trusted-device retry after shared token mismatch.
    // Blocking reconnect on mismatch here would skip that bounded recovery attempt.
    expect(isNonRecoverableAuthError(makeError(ConnectErrorDetailCodes.AUTH_TOKEN_MISMATCH))).toBe(
      false,
    );
  });

  it("allows reconnect for unrecognized detail codes (future-proof)", () => {
    expect(isNonRecoverableAuthError(makeError("SOME_FUTURE_CODE"))).toBe(false);
  });
});

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge