The rename commit before this one covered module paths and the obvious user-facing strings; this is the rest of it -- the places where "sentry" was a default value, a filename, or a picture rather than a word in a sentence. Defaults that changed: CLICKHOUSE_DATABASE (sentry -> cairnobs), POSTGRES_DATABASE (sentry_metadata -> cairnobs_metadata), and POSTGRES_USERNAME (sentry -> cairnobs), across api/alerting/ingest and the enterprise binaries, plus the compose files and migrate scripts that create those objects. These are *defaults*, so a deployment that sets them explicitly is unaffected -- but any deployment relying on the old defaults must have its environment updated before it picks this up, or it will come up pointing at a database that doesn't exist. Also: the light-mode logo variants (the dark ones existed alone, so the landing page and sidebar rendered a dark mark on a light background), regenerated favicons, and the docs/README/threat-model prose that still said Sentry.
62 lines
1.7 KiB
Go
62 lines
1.7 KiB
Go
package saml
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/crewjam/saml"
|
|
)
|
|
|
|
func fakeIDPMetadata() *saml.EntityDescriptor {
|
|
return &saml.EntityDescriptor{
|
|
EntityID: "https://idp.example.com/metadata",
|
|
IDPSSODescriptors: []saml.IDPSSODescriptor{
|
|
{
|
|
SingleSignOnServices: []saml.Endpoint{
|
|
{Binding: saml.HTTPRedirectBinding, Location: "https://idp.example.com/sso"},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func TestNewRejectsMissingConfig(t *testing.T) {
|
|
_, err := New(Config{})
|
|
if err == nil {
|
|
t.Fatalf("expected an error for an empty config")
|
|
}
|
|
}
|
|
|
|
func TestNewRejectsMissingIDPMetadata(t *testing.T) {
|
|
_, err := New(Config{EntityID: "https://cairnobs.example.com/saml/metadata", ACSURL: "https://cairnobs.example.com/saml/acs"})
|
|
if err == nil {
|
|
t.Fatalf("expected an error when IDPMetadata is missing")
|
|
}
|
|
}
|
|
|
|
// TestLoginURLBuildsAgainstRealIDPMetadata exercises the actual
|
|
// crewjam/saml AuthnRequest-building and redirect-encoding path (deflate
|
|
// + base64 + query-string construction) against IdP metadata shaped like
|
|
// what a real IdP publishes, confirming the wiring produces a usable
|
|
// redirect rather than just "the code compiles."
|
|
func TestLoginURLBuildsAgainstRealIDPMetadata(t *testing.T) {
|
|
sp, err := New(Config{
|
|
EntityID: "https://cairnobs.example.com/saml/metadata",
|
|
ACSURL: "https://cairnobs.example.com/saml/acs",
|
|
IDPMetadata: fakeIDPMetadata(),
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
|
|
redirectURL, requestID, err := sp.LoginURL("relay-state-123")
|
|
if err != nil {
|
|
t.Fatalf("LoginURL: %v", err)
|
|
}
|
|
if redirectURL == "" {
|
|
t.Fatalf("expected a non-empty redirect URL")
|
|
}
|
|
if requestID == "" {
|
|
t.Fatalf("expected a non-empty AuthnRequest ID -- callers need this for ParseResponse's possibleRequestIDs")
|
|
}
|
|
}
|