-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhttps_url_test.go
More file actions
36 lines (27 loc) · 888 Bytes
/
Copy pathhttps_url_test.go
File metadata and controls
36 lines (27 loc) · 888 Bytes
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
package zerobouncego
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRequireHTTPS(t *testing.T) {
ok, err := requireHTTPS("https://api.zerobounce.net/v2/")
assert.NoError(t, err)
assert.Equal(t, "https://api.zerobounce.net/v2/", ok)
_, err = requireHTTPS("http://example.com")
assert.Error(t, err)
_, err = requireHTTPS("file:///etc/passwd")
assert.Error(t, err)
empty, err := requireHTTPS("")
assert.NoError(t, err)
assert.Equal(t, "", empty)
}
func TestSetURIIgnoresNonHTTPS(t *testing.T) {
prevURI, prevBulk := URI, BULK_URI
t.Cleanup(func() {
URI, BULK_URI = prevURI, prevBulk
})
SetURI("https://api-eu.zerobounce.net/v2/", "https://bulkapi.zerobounce.net/v2/")
assert.Equal(t, "https://api-eu.zerobounce.net/v2/", URI)
SetURI("http://evil.example/", "http://evil.example/")
assert.Equal(t, "https://api-eu.zerobounce.net/v2/", URI)
}