| 1 |
package oidc |
| 2 |
|
| 3 |
// This file contains common functions and data for regression testing |
| 4 |
|
| 5 |
import ( |
| 6 |
"encoding/json" |
| 7 |
"fmt" |
| 8 |
"io" |
| 9 |
"path" |
| 10 |
"strings" |
| 11 |
"testing" |
| 12 |
|
| 13 |
"github.com/stretchr/testify/require" |
| 14 |
) |
| 15 |
|
| 16 |
const dataDir = "regression_data" |
| 17 |
|
| 18 |
// jsonFilename builds a filename for the regression testdata. |
| 19 |
// dataDir/<type_name>.json |
| 20 |
func jsonFilename(obj any) string { |
| 21 |
name := fmt.Sprintf("%T.json", obj) |
| 22 |
return path.Join( |
| 23 |
dataDir, |
| 24 |
strings.TrimPrefix(name, "*"), |
| 25 |
) |
| 26 |
} |
| 27 |
|
| 28 |
func encodeJSON(t *testing.T, w io.Writer, obj any) { |
| 29 |
enc := json.NewEncoder(w) |
| 30 |
enc.SetIndent("", "\t") |
| 31 |
require.NoError(t, enc.Encode(obj)) |
| 32 |
} |
| 33 |
|
| 34 |
var regressionData = []any{ |
| 35 |
accessTokenData, |
| 36 |
idTokenData, |
| 37 |
introspectionResponseData, |
| 38 |
userInfoData, |
| 39 |
jwtProfileAssertionData, |
| 40 |
} |