Repository navigation
Expand file tree
/
Copy pathcmd_signup_test.go
More file actions
37 lines (34 loc) · 1.64 KB
/
Copy pathcmd_signup_test.go
File metadata and controls
37 lines (34 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import "testing"
// The console URL is derived from the session's API host rather than listed,
// so a new deployment needs no code change here. A host we do not recognize
// must fall back to production rather than to a guess: sending someone to a
// made-up console is worse than sending them to the real one.
func TestSignupURL(t *testing.T) {
t.Cleanup(func() { gConfig = NewConfig(); fBaseURL = "" })
for _, tt := range []struct {
base, want string
}{
{"", "https://app.internetdata.io/auth/signup"},
// The API is served at the apex, so there is no `api` label to swap.
{"https://internetdata.io", "https://app.internetdata.io/auth/signup"},
{"https://internetdata.io/", "https://app.internetdata.io/auth/signup"},
{"https://internetdata.io:8443", "https://app.internetdata.io/auth/signup"},
{"https://eu.internetdata.io", "https://app-eu.internetdata.io/auth/signup"},
// An api-labeled host keeps the sibling shape.
{"https://api.internetdata.io", "https://app.internetdata.io/auth/signup"},
{"https://api-eu.internetdata.io", "https://app-eu.internetdata.io/auth/signup"},
// Nothing else is ours to rewrite.
{"https://a.b.internetdata.io", "https://app.internetdata.io/auth/signup"},
{"https://notinternetdata.io", "https://app.internetdata.io/auth/signup"},
{"https://api.example.com", "https://app.internetdata.io/auth/signup"},
{"https://example.com", "https://app.internetdata.io/auth/signup"},
{"://broken", "https://app.internetdata.io/auth/signup"},
} {
gConfig = NewConfig()
fBaseURL = tt.base
if got := signupURL(); got != tt.want {
t.Errorf("base %q: got %q, want %q", tt.base, got, tt.want)
}
}
}