-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
54 lines (45 loc) · 1.28 KB
/
main_test.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"testing"
)
//TODO: enter proper credentials here
const validHost = "http://localhost"
const validToken = "4a6244683f471d73abf96870aa3b41d025c90aba"
const invalidHost = "http://example.com"
const invalidToken = "invalidtoken"
func TestValidateHostValid(t *testing.T) {
err := ValidateHost(validHost)
if err != nil {
t.Error("Given valid host, ValidateHost returned ", err)
}
}
func TestValidateHostInvalid(t *testing.T) {
err := ValidateHost(invalidHost)
if err == nil {
t.Error("Given invalid host, ValidateHost returned ", err)
}
}
func TestValidateTokenBothValid(t *testing.T) {
err := ValidateToken(validHost, validToken)
if err != nil {
t.Error("Given valid credentials, ValidateToken returned ", err)
}
}
func TestValidateTokenInvalidHost(t *testing.T) {
err := ValidateToken(invalidHost, validToken)
if err == nil {
t.Error("Given invalid host, ValidateToken returned ", err)
}
}
func TestValidateTokenInvalidToken(t *testing.T) {
err := ValidateToken(validHost, invalidToken)
if err == nil {
t.Error("Given invalid token, ValidateToken returned ", err)
}
}
func TestValidateTokenBothInvalid(t *testing.T) {
err := ValidateToken(invalidHost, invalidToken)
if err == nil {
t.Error("Given invalid host and token, ValidateToken returned ", err)
}
}