MCPcopy Create free account
hub / github.com/auth0/auth0-cli / TestReplaceDetectionSub

Function TestReplaceDetectionSub

internal/cli/quickstart_detect_test.go:1643–1782  ·  view source on GitHub ↗

-- replaceDetectionSub --.

(t *testing.T)

Source from the content-addressed store, hash-verified

1641// -- replaceDetectionSub --.
1642
1643func TestReplaceDetectionSub(t *testing.T) {
1644 const sub = auth0.DetectionSub
1645 const domain = "tenant.auth0.com"
1646
1647 clientID := "test-client-id"
1648 clientSecret := "test-client-secret"
1649 client := &management.Client{
1650 ClientID: &clientID,
1651 ClientSecret: &clientSecret,
1652 }
1653
1654 t.Run("domain keys", func(t *testing.T) {
1655 domainKeys := []string{
1656 "VITE_AUTH0_DOMAIN",
1657 "AUTH0_DOMAIN",
1658 "NUXT_AUTH0_DOMAIN",
1659 "EXPO_PUBLIC_AUTH0_DOMAIN",
1660 "domain",
1661 "auth0.domain",
1662 "auth0/domain",
1663 "Auth0:Domain",
1664 "auth0:Domain",
1665 "auth0_domain",
1666 }
1667 for _, key := range domainKeys {
1668 t.Run(key, func(t *testing.T) {
1669 got, err := replaceDetectionSub(map[string]string{key: sub}, domain, client, 3000)
1670 require.NoError(t, err)
1671 assert.Equal(t, domain, got[key])
1672 })
1673 }
1674 })
1675
1676 t.Run("ISSUER_BASE_URL gets https prefix", func(t *testing.T) {
1677 got, err := replaceDetectionSub(map[string]string{"ISSUER_BASE_URL": sub}, domain, client, 3000)
1678 require.NoError(t, err)
1679 assert.Equal(t, "https://"+domain, got["ISSUER_BASE_URL"])
1680 })
1681
1682 t.Run("okta issuer gets https prefix and trailing slash", func(t *testing.T) {
1683 got, err := replaceDetectionSub(map[string]string{"okta.oauth2.issuer": sub}, domain, client, 3000)
1684 require.NoError(t, err)
1685 assert.Equal(t, "https://"+domain+"/", got["okta.oauth2.issuer"])
1686 })
1687
1688 t.Run("client ID keys", func(t *testing.T) {
1689 clientIDKeys := []string{
1690 "VITE_AUTH0_CLIENT_ID",
1691 "AUTH0_CLIENT_ID",
1692 "CLIENT_ID",
1693 "EXPO_PUBLIC_AUTH0_CLIENT_ID",
1694 "NUXT_AUTH0_CLIENT_ID",
1695 "clientId",
1696 "auth0.clientId",
1697 "auth0/clientId",
1698 "okta.oauth2.client-id",
1699 "Auth0:ClientId",
1700 "auth0:ClientId",

Callers

nothing calls this directly

Calls 1

replaceDetectionSubFunction · 0.85

Tested by

no test coverage detected