testing/e2e: add API helper for u/pw credentials

pull/4202/head
Johan Brandhorst-Satzkorn 2 years ago
parent 0b1217fdb6
commit 7dce5396f5

@ -142,3 +142,19 @@ func CreateNewStaticCredentialJsonCli(t testing.TB, ctx context.Context, credent
return newCredentialsId
}
// CreateNewStaticCredentialPasswordApi uses the API to create a new password credential in the
// provided static credential store.
// Returns the id of the new credential
func CreateNewStaticCredentialPasswordApi(t testing.TB, ctx context.Context, client *api.Client, credentialStoreId string, user string, password string) string {
c := credentials.NewClient(client)
newCredentialsResult, err := c.Create(ctx, "username_password", credentialStoreId,
credentials.WithUsernamePasswordCredentialUsername(user),
credentials.WithUsernamePasswordCredentialPassword(password),
)
require.NoError(t, err)
newCredentialsId := newCredentialsResult.Item.Id
t.Logf("Created Username/Password Credentials: %s", newCredentialsId)
return newCredentialsId
}

Loading…
Cancel
Save