Skip to content

Commit

Permalink
feat: add test helper for fetching settings requests
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Aug 25, 2020
1 parent 60664aa commit 3646383
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions internal/testhelpers/selfservice_settings.go
Expand Up @@ -158,14 +158,13 @@ func AddAndLoginIdentities(t *testing.T, reg *driver.RegistryDefault, public *ht
return result
}

func SettingsSubmitForm(
func SettingsMakeRequest(
t *testing.T,
isAPI bool,
f *models.FlowMethodConfig,
hc *http.Client,
values string,
expectedStatusCode int,
) (string, *common.GetSelfServiceSettingsFlowOK) {
) (string, *http.Response) {
require.NotEmpty(t, f.Action)

req, err := http.NewRequest("POST", pointerx.StringR(f.Action), bytes.NewBufferString(values))
Expand All @@ -182,7 +181,18 @@ func SettingsSubmitForm(
require.NoError(t, err)
defer res.Body.Close()

b := x.MustReadAll(res.Body)
return string(x.MustReadAll(res.Body)), res
}

func SettingsSubmitForm(
t *testing.T,
isAPI bool,
f *models.FlowMethodConfig,
hc *http.Client,
values string,
expectedStatusCode int,
) (string, *common.GetSelfServiceSettingsFlowOK) {
b, res := SettingsMakeRequest(t,isAPI,f,hc,values)
assert.EqualValues(t, expectedStatusCode, res.StatusCode, "%s", b)

expectURL := viper.GetString(configuration.ViperKeySelfServiceSettingsURL)
Expand Down

0 comments on commit 3646383

Please sign in to comment.