newSAMLTestAPI builds a minimal API with SAML enabled using the given key(s).
(t *tst.T, primaryKey, nextKey string, allowEncrypted bool)
| 66 | |
| 67 | // newSAMLTestAPI builds a minimal API with SAML enabled using the given key(s). |
| 68 | func newSAMLTestAPI(t *tst.T, primaryKey, nextKey string, allowEncrypted bool) (*API, error) { |
| 69 | t.Helper() |
| 70 | config, err := confload.LoadGlobal(apiTestConfig) |
| 71 | if err != nil { |
| 72 | return nil, err |
| 73 | } |
| 74 | config.API.ExternalURL = "https://projectref.supabase.co/auth/v1/" |
| 75 | config.API.MaxRequestDuration = 5 * time.Second |
| 76 | config.SAML.Enabled = true |
| 77 | config.SAML.PrivateKey = primaryKey |
| 78 | config.SAML.PrivateKeyNext = nextKey |
| 79 | config.SAML.AllowEncryptedAssertions = allowEncrypted |
| 80 | if err := config.ApplyDefaults(); err != nil { |
| 81 | return nil, err |
| 82 | } |
| 83 | if err := config.SAML.PopulateFields(config.API.ExternalURL); err != nil { |
| 84 | return nil, err |
| 85 | } |
| 86 | return NewAPI(config, nil), nil |
| 87 | } |
| 88 | |
| 89 | // samlMetadataRequest issues a GET /sso/saml/metadata and parses the response. |
| 90 | func samlMetadataRequest(t *tst.T, api *API) (*saml.EntityDescriptor, http.Header) { |
no test coverage detected