2022-01-24 20:41:15 +00:00
|
|
|
package application
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2022-03-03 09:40:07 +00:00
|
|
|
"goauthentik.io/api/v3"
|
2022-01-24 20:41:15 +00:00
|
|
|
"goauthentik.io/internal/outpost/ak"
|
|
|
|
)
|
|
|
|
|
2023-02-12 15:34:57 +00:00
|
|
|
type testServer struct {
|
|
|
|
api *ak.APIController
|
|
|
|
apps []*Application
|
|
|
|
}
|
|
|
|
|
|
|
|
func newTestServer() *testServer {
|
|
|
|
return &testServer{
|
|
|
|
api: ak.MockAK(
|
|
|
|
api.Outpost{
|
|
|
|
Config: map[string]interface{}{
|
|
|
|
"authentik_host": ak.TestSecret(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ak.MockConfig(),
|
|
|
|
),
|
|
|
|
apps: make([]*Application, 0),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ts *testServer) API() *ak.APIController {
|
|
|
|
return ts.api
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ts *testServer) CryptoStore() *ak.CryptoStore {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ts *testServer) Apps() []*Application {
|
|
|
|
return ts.apps
|
|
|
|
}
|
|
|
|
|
2022-01-24 20:41:15 +00:00
|
|
|
func newTestApplication() *Application {
|
2023-02-12 15:34:57 +00:00
|
|
|
ts := newTestServer()
|
2022-01-24 20:41:15 +00:00
|
|
|
a, _ := NewApplication(
|
|
|
|
api.ProxyOutpostConfig{
|
|
|
|
Name: ak.TestSecret(),
|
|
|
|
ClientId: api.PtrString(ak.TestSecret()),
|
|
|
|
ClientSecret: api.PtrString(ak.TestSecret()),
|
|
|
|
CookieSecret: api.PtrString(ak.TestSecret()),
|
2022-02-15 12:43:55 +00:00
|
|
|
ExternalHost: "https://ext.t.goauthentik.io",
|
2022-09-22 08:10:29 +00:00
|
|
|
InternalHost: api.PtrString("http://backend"),
|
|
|
|
InternalHostSslValidation: api.PtrBool(true),
|
2022-01-24 20:41:15 +00:00
|
|
|
CookieDomain: api.PtrString(""),
|
2023-04-01 16:10:52 +00:00
|
|
|
Mode: api.PROXYMODE_FORWARD_SINGLE.Ptr(),
|
2022-01-24 20:41:15 +00:00
|
|
|
SkipPathRegex: api.PtrString("/skip.*"),
|
|
|
|
BasicAuthEnabled: api.PtrBool(true),
|
|
|
|
BasicAuthUserAttribute: api.PtrString("username"),
|
|
|
|
BasicAuthPasswordAttribute: api.PtrString("password"),
|
2023-04-01 16:10:52 +00:00
|
|
|
OidcConfiguration: api.OpenIDConnectConfiguration{
|
2022-07-30 15:51:01 +00:00
|
|
|
AuthorizationEndpoint: "http://fake-auth.t.goauthentik.io/auth",
|
|
|
|
TokenEndpoint: "http://fake-auth.t.goauthentik.io/token",
|
|
|
|
UserinfoEndpoint: "http://fake-auth.t.goauthentik.io/userinfo",
|
|
|
|
},
|
2022-01-24 20:41:15 +00:00
|
|
|
},
|
|
|
|
http.DefaultClient,
|
2023-02-12 15:34:57 +00:00
|
|
|
ts,
|
2022-01-24 20:41:15 +00:00
|
|
|
)
|
2023-02-12 15:34:57 +00:00
|
|
|
ts.apps = append(ts.apps, a)
|
2022-01-24 20:41:15 +00:00
|
|
|
return a
|
|
|
|
}
|