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