oficina / suite Public

Clone
git clone https://amadan.net/oficina/suite

Plain git — no account needed to clone.

Download

Download this file

1package suite
2
3import (
4 "errors"
5 "net/http"
6 "strings"
7 "testing"
8)
9
10func TestSiblingClientRefusesPlaintextBeforeSendingCredentials(t *testing.T) {
11 d := &recordingDialer{}
12 c := NewSiblingClient("acme", d.dial)
13 req, err := http.NewRequest("POST", "http://acme.docs.oficina.works/suite/s2", strings.NewReader(`{"item_id":"fixture"}`))
14 if err != nil {
15 t.Fatal(err)
16 }
17 req.Header.Set("Authorization", "Bearer synthetic-fixture")
18 _, err = c.Do(req)
19 if !errors.Is(err, ErrContractBreach) {
20 t.Errorf("plain HTTP returned %v; want contract refusal", err)
21 }
22 if len(d.dialed) != 0 {
23 t.Errorf("plaintext credential request attempted network connection: %v", d.dialed)
24 }
25}
26