-
-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfc11af
commit 59a48f2
Showing
2 changed files
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,14 +125,58 @@ func TestEngineXNavigate(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestEngineXInternalURL(t *testing.T) { | ||
t.Run("destination is internal URL", func(t *testing.T) { | ||
os.Setenv("GOAPP_INTERNAL_URLS", `["https://murlok.io"]`) | ||
defer os.Unsetenv("GOAPP_INTERNAL_URLS") | ||
|
||
e := newTestEngine() | ||
destination, _ := url.Parse("https://murlok.io/warrior") | ||
require.True(t, e.internalURL(destination)) | ||
}) | ||
|
||
t.Run("destination is internal URL", func(t *testing.T) { | ||
e := newTestEngine() | ||
destination, _ := url.Parse("https://murlok.io/warrior") | ||
require.False(t, e.internalURL(destination)) | ||
}) | ||
} | ||
|
||
func TestEngineXMailTo(t *testing.T) { | ||
t.Run("destination is mailto", func(t *testing.T) { | ||
e := newTestEngine() | ||
destination, _ := url.Parse("mailto:[email protected]") | ||
require.True(t, e.mailTo(destination)) | ||
}) | ||
|
||
t.Run("destination is not mailto", func(t *testing.T) { | ||
e := newTestEngine() | ||
destination, _ := url.Parse("/hello") | ||
require.False(t, e.mailTo(destination)) | ||
}) | ||
} | ||
|
||
func TestEngineXExternalNavigation(t *testing.T) { | ||
t.Run("destination is external navigation", func(t *testing.T) { | ||
e := newTestEngine() | ||
destination, _ := url.Parse("https://murlok.io") | ||
require.True(t, e.externalNavigation(destination)) | ||
}) | ||
|
||
t.Run("destination is not external navigation", func(t *testing.T) { | ||
e := newTestEngine() | ||
destination, _ := url.Parse("/hello") | ||
require.False(t, e.externalNavigation(destination)) | ||
}) | ||
} | ||
|
||
func newTestEngine() *engineX { | ||
url, _ := url.Parse("/") | ||
origin, _ := url.Parse("/") | ||
routes := makeRouter() | ||
|
||
return newEngineX(context.Background(), | ||
&routes, | ||
nil, | ||
url, | ||
origin, | ||
Body, | ||
) | ||
} |