mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-01-05 13:07:14 +00:00
Extract testutil helper function
This commit is contained in:
@@ -6,10 +6,13 @@ package testutil
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.pinniped.dev/internal/federationdomain/stateparam"
|
||||
)
|
||||
|
||||
func RequireLogLines(t *testing.T, wantLogs []string, log *bytes.Buffer) {
|
||||
@@ -38,6 +41,17 @@ func WantAuditLog(message string, params map[string]any, auditID ...string) Want
|
||||
return result
|
||||
}
|
||||
|
||||
func GetStateParam(t *testing.T, fullURL string) stateparam.Encoded {
|
||||
var encodedStateParam stateparam.Encoded
|
||||
if fullURL != "" {
|
||||
path, err := url.Parse(fullURL)
|
||||
require.NoError(t, err)
|
||||
encodedStateParam = stateparam.Encoded(path.Query().Get("state"))
|
||||
}
|
||||
|
||||
return encodedStateParam
|
||||
}
|
||||
|
||||
func CompareAuditLogs(t *testing.T, wantAuditLogs []WantedAuditLog, actualAuditLogsOneLiner string) {
|
||||
t.Helper()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user