MCPcopy
hub / github.com/zitadel/oidc / TestBuildAuthResponseCodeResponsePayload

Function TestBuildAuthResponseCodeResponsePayload

pkg/op/auth_request_test.go:1237–1362  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1235}
1236
1237func TestBuildAuthResponseCodeResponsePayload(t *testing.T) {
1238 type args struct {
1239 authReq op.AuthRequest
1240 authorizer func(*testing.T) op.Authorizer
1241 }
1242 type res struct {
1243 wantCode string
1244 wantState string
1245 wantSessionState string
1246 wantErr bool
1247 }
1248 tests := []struct {
1249 name string
1250 args args
1251 res res
1252 }{
1253 {
1254 name: "create code error",
1255 args: args{
1256 authReq: &storage.AuthRequest{
1257 ID: "id1",
1258 },
1259 authorizer: func(t *testing.T) op.Authorizer {
1260 ctrl := gomock.NewController(t)
1261 storage := mock.NewMockStorage(ctrl)
1262
1263 authorizer := mock.NewMockAuthorizer(ctrl)
1264 authorizer.EXPECT().Storage().Return(storage)
1265 authorizer.EXPECT().Crypto().Return(&mockCrypto{
1266 returnErr: io.ErrClosedPipe,
1267 })
1268 return authorizer
1269 },
1270 },
1271 res: res{
1272 wantErr: true,
1273 },
1274 },
1275 {
1276 name: "success with state",
1277 args: args{
1278 authReq: &storage.AuthRequest{
1279 ID: "id1",
1280 TransferState: "state1",
1281 },
1282 authorizer: func(t *testing.T) op.Authorizer {
1283 ctrl := gomock.NewController(t)
1284 storage := mock.NewMockStorage(ctrl)
1285 storage.EXPECT().SaveAuthCode(gomock.Any(), "id1", "id1")
1286
1287 authorizer := mock.NewMockAuthorizer(ctrl)
1288 authorizer.EXPECT().Storage().Return(storage)
1289 authorizer.EXPECT().Crypto().Return(&mockCrypto{})
1290 return authorizer
1291 },
1292 },
1293 res: res{
1294 wantCode: "id1",

Callers

nothing calls this directly

Calls 9

EXPECTMethod · 0.95
EXPECTMethod · 0.95
NewMockStorageFunction · 0.92
NewMockAuthorizerFunction · 0.92
StorageMethod · 0.65
CryptoMethod · 0.65
SaveAuthCodeMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…