MCPcopy Create free account
hub / github.com/crewjam/saml / TestCreateLinkStoresTargetAndOwner

Function TestCreateLinkStoresTargetAndOwner

example/service_test.go:46–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

44}
45
46func TestCreateLinkStoresTargetAndOwner(t *testing.T) {
47 resetLinks(t)
48
49 a := createLink(t, "https://example.com/a", "alice@example.com")
50 b := createLink(t, "https://example.com/b", "alice@example.com")
51 if a == b {
52 t.Fatalf("two links got the same short name %q", a)
53 }
54
55 mux := http.NewServeMux()
56 mux.HandleFunc("GET /{link}", ServeLink)
57 for short, want := range map[string]string{a: "https://example.com/a", b: "https://example.com/b"} {
58 w := httptest.NewRecorder()
59 mux.ServeHTTP(w, httptest.NewRequest(http.MethodGet, "/"+short, nil))
60 if got := w.Header().Get("Location"); w.Code != http.StatusFound || got != want {
61 t.Errorf("GET /%s = %d Location %q, want 302 %q", short, w.Code, got, want)
62 }
63 }
64}
65
66func TestListLinksUsesSessionNotHeader(t *testing.T) {
67 resetLinks(t)

Callers

nothing calls this directly

Calls 6

resetLinksFunction · 0.85
createLinkFunction · 0.85
FatalfMethod · 0.80
ServeHTTPMethod · 0.80
GetMethod · 0.65
HeaderMethod · 0.45

Tested by

no test coverage detected