2021-12-22 15:31:45 +05:30
|
|
|
package test
|
2021-12-11 06:41:35 +05:30
|
|
|
|
2021-12-20 17:33:11 +05:30
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-05-30 11:54:16 +05:30
|
|
|
"github.com/authorizerdev/authorizer/server/parsers"
|
2021-12-20 17:33:11 +05:30
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
2021-12-11 06:41:35 +05:30
|
|
|
|
|
|
|
func TestGetHostName(t *testing.T) {
|
2022-01-31 11:35:24 +05:30
|
|
|
url := "http://test.herokuapp.com:80"
|
2021-12-11 06:41:35 +05:30
|
|
|
|
2022-05-30 11:54:16 +05:30
|
|
|
host, port := parsers.GetHostParts(url)
|
2021-12-21 18:46:54 +05:30
|
|
|
expectedHost := "test.herokuapp.com"
|
2021-12-11 06:41:35 +05:30
|
|
|
|
2021-12-21 18:46:54 +05:30
|
|
|
assert.Equal(t, host, expectedHost, "hostname should be equal")
|
|
|
|
assert.Equal(t, port, "80", "port should be 80")
|
2021-12-11 06:41:35 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetDomainName(t *testing.T) {
|
2022-01-31 11:35:24 +05:30
|
|
|
url := "http://test.herokuapp.com"
|
2021-12-11 06:41:35 +05:30
|
|
|
|
2022-05-30 12:47:50 +05:30
|
|
|
got := parsers.GetDomainName(url)
|
2021-12-11 06:41:35 +05:30
|
|
|
want := "herokuapp.com"
|
|
|
|
|
2021-12-20 17:33:11 +05:30
|
|
|
assert.Equal(t, got, want, "domain name should be equal")
|
2021-12-11 06:41:35 +05:30
|
|
|
}
|