mirror of
https://github.com/grafana/grafana.git
synced 2026-08-13 06:34:55 -05:00
API: Fix redirect issues (#22285)
* Revert "API: Fix redirect issue when configured to use a subpath (#21652)" (#22671)
This reverts commit 0e2d874ecf.
* Fix redirect validation (#22675)
* Chore: Add test for parse of app url and app sub url
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
* Fix redirect: prepend subpath only if it's missing (#22676)
* Validate redirect in login oauth (#22677)
* Fix invalid redirect for authenticated user (#22678)
* Login: Use correct path for OAuth logos
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:
co-authored by
Marcus Efraimsson
parent
688283a5cc
commit
be022d4239
@@ -9,6 +9,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"gopkg.in/ini.v1"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
@@ -298,3 +300,28 @@ func TestLoadingSettings(t *testing.T) {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
func TestParseAppUrlAndSubUrl(t *testing.T) {
|
||||
testCases := []struct {
|
||||
rootURL string
|
||||
expectedAppURL string
|
||||
expectedAppSubURL string
|
||||
}{
|
||||
{rootURL: "http://localhost:3000/", expectedAppURL: "http://localhost:3000/"},
|
||||
{rootURL: "http://localhost:3000", expectedAppURL: "http://localhost:3000/"},
|
||||
{rootURL: "http://localhost:3000/grafana", expectedAppURL: "http://localhost:3000/grafana/", expectedAppSubURL: "/grafana"},
|
||||
{rootURL: "http://localhost:3000/grafana/", expectedAppURL: "http://localhost:3000/grafana/", expectedAppSubURL: "/grafana"},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
f := ini.Empty()
|
||||
s, err := f.NewSection("server")
|
||||
require.NoError(t, err)
|
||||
_, err = s.NewKey("root_url", tc.rootURL)
|
||||
require.NoError(t, err)
|
||||
appURL, appSubURL, err := parseAppUrlAndSubUrl(s)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.expectedAppURL, appURL)
|
||||
require.Equal(t, tc.expectedAppSubURL, appSubURL)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user