snapshot of https://github.com/ory/kratos.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
This commit is contained in:
70
hydra/fake.go
Normal file
70
hydra/fake.go
Normal file
@@ -0,0 +1,70 @@
|
||||
// Copyright © 2023 Ory Corp
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package hydra
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/ory/herodot"
|
||||
hydraclientgo "github.com/ory/hydra-client-go/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
FakeInvalidLoginChallenge = "2e98454e-031b-4870-9ad6-8517df1ce604"
|
||||
FakeValidLoginChallenge = "5ff59a39-ecc5-467e-bb10-26644c0700ee"
|
||||
FakePostLoginURL = "https://www.example.com/fake-post-login"
|
||||
FakeClientID = "fake-oauth2-client-id"
|
||||
FakeClientName = "Fake OAuth2 Client"
|
||||
FakeClientLogoURI = "https://www.example.com/logo.png"
|
||||
)
|
||||
|
||||
var ErrFakeAcceptLoginRequestFailed = errors.New("failed to accept login request")
|
||||
|
||||
type FakeHydra struct {
|
||||
Skip bool
|
||||
RequestURL string
|
||||
}
|
||||
|
||||
var _ Hydra = &FakeHydra{}
|
||||
|
||||
func NewFake() *FakeHydra {
|
||||
return &FakeHydra{
|
||||
RequestURL: "https://www.ory.com",
|
||||
}
|
||||
}
|
||||
|
||||
func (h *FakeHydra) AcceptLoginRequest(_ context.Context, params AcceptLoginRequestParams) (string, error) {
|
||||
if params.SessionID == "" {
|
||||
return "", errors.New("session id must not be empty")
|
||||
}
|
||||
switch params.LoginChallenge {
|
||||
case FakeInvalidLoginChallenge:
|
||||
return "", ErrFakeAcceptLoginRequestFailed
|
||||
case FakeValidLoginChallenge:
|
||||
return FakePostLoginURL, nil
|
||||
default:
|
||||
panic("unknown fake login_challenge " + params.LoginChallenge)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *FakeHydra) GetLoginRequest(_ context.Context, loginChallenge string) (*hydraclientgo.OAuth2LoginRequest, error) {
|
||||
switch loginChallenge {
|
||||
case FakeInvalidLoginChallenge:
|
||||
return nil, herodot.ErrBadRequest().WithReasonf("Unable to get OAuth 2.0 Login Challenge.")
|
||||
case FakeValidLoginChallenge:
|
||||
return &hydraclientgo.OAuth2LoginRequest{
|
||||
Challenge: loginChallenge,
|
||||
RequestUrl: h.RequestURL,
|
||||
Skip: h.Skip,
|
||||
Client: hydraclientgo.OAuth2Client{
|
||||
ClientId: hydraclientgo.PtrString(FakeClientID),
|
||||
ClientName: hydraclientgo.PtrString(FakeClientName),
|
||||
LogoUri: hydraclientgo.PtrString(FakeClientLogoURI),
|
||||
},
|
||||
}, nil
|
||||
default:
|
||||
panic("unknown fake login_challenge " + loginChallenge)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user