-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ui): stop using /meta/config endpoint (#3684)
/meta/config exposes too much configuration and UI doesn't need that much. There were few leakage of the secrets as people provide configuration options in their way and that fire seem never to stop. The global idea is to drop /meta/config endpoint and this is a first step to it.
- Loading branch information
Showing
16 changed files
with
203 additions
and
74 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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestStorageConfigInfo(t *testing.T) { | ||
tests := []struct { | ||
config StorageConfig | ||
expected map[string]string | ||
}{ | ||
{StorageConfig{Type: DatabaseStorageType}, nil}, | ||
{StorageConfig{Type: GitStorageType, Git: &StorageGitConfig{Repository: "repo1", Ref: "v1.0.0"}}, map[string]string{ | ||
"ref": "v1.0.0", "repository": "repo1", | ||
}}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(string(tt.config.Type), func(t *testing.T) { | ||
assert.Equal(t, tt.expected, tt.config.Info()) | ||
}) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package info | ||
|
||
import ( | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"go.flipt.io/flipt/internal/config" | ||
"go.flipt.io/flipt/internal/release" | ||
) | ||
|
||
func TestNew(t *testing.T) { | ||
f := New( | ||
WithOS("linux", "amd64"), | ||
WithBuild("commit", "date", "goVersion", "version", true), | ||
WithLatestRelease(release.Info{LatestVersion: "latestVersion", LatestVersionURL: "latestVersionURL", UpdateAvailable: true}), | ||
WithConfig(config.Default()), | ||
) | ||
|
||
assert.Equal(t, "commit", f.Commit) | ||
assert.Equal(t, "date", f.BuildDate) | ||
assert.Equal(t, "goVersion", f.GoVersion) | ||
assert.Equal(t, "version", f.Version) | ||
assert.True(t, f.IsRelease) | ||
assert.Equal(t, "latestVersion", f.LatestVersion) | ||
assert.Equal(t, "latestVersionURL", f.LatestVersionURL) | ||
assert.True(t, f.UpdateAvailable) | ||
assert.Equal(t, "linux", f.OS) | ||
assert.Equal(t, "amd64", f.Arch) | ||
assert.False(t, f.Authentication.Required) | ||
assert.False(t, f.Analytics.Enabled) | ||
assert.Equal(t, config.DatabaseStorageType, f.Storage.Type) | ||
} | ||
|
||
func TestHttpHandler(t *testing.T) { | ||
f := New() | ||
f.Storage.Type = config.DatabaseStorageType | ||
r := httptest.NewRequest("GET", "/info", nil) | ||
w := httptest.NewRecorder() | ||
f.ServeHTTP(w, r) | ||
assert.Equal(t, http.StatusOK, w.Code) | ||
assert.Equal(t, `{"updateAvailable":false,"isRelease":false,"authentication":{"required":false},"storage":{"type":"database"}}`, w.Body.String()) | ||
} |
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
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
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
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
Oops, something went wrong.