-- resolveRequestParams --.
(t *testing.T)
| 1590 | // -- resolveRequestParams --. |
| 1591 | |
| 1592 | func TestResolveRequestParams(t *testing.T) { |
| 1593 | const sub = auth0.DetectionSub |
| 1594 | |
| 1595 | t.Run("DetectionSub replaced in callbacks", func(t *testing.T) { |
| 1596 | req := auth0.RequestParams{ |
| 1597 | AppType: "spa", |
| 1598 | Callbacks: []string{sub}, |
| 1599 | AllowedLogoutURLs: []string{sub}, |
| 1600 | WebOrigins: []string{sub}, |
| 1601 | Name: sub, |
| 1602 | } |
| 1603 | got := resolveRequestParams(req, "MyApp", 3000) |
| 1604 | assert.Equal(t, []string{"http://localhost:3000/callback"}, got.Callbacks) |
| 1605 | assert.Equal(t, []string{"http://localhost:3000"}, got.AllowedLogoutURLs) |
| 1606 | assert.Equal(t, []string{"http://localhost:3000"}, got.WebOrigins) |
| 1607 | assert.Equal(t, "MyApp", got.Name) |
| 1608 | assert.Equal(t, "spa", got.AppType) |
| 1609 | }) |
| 1610 | |
| 1611 | t.Run("port 0 defaults to 3000", func(t *testing.T) { |
| 1612 | req := auth0.RequestParams{Callbacks: []string{sub}} |
| 1613 | got := resolveRequestParams(req, "App", 0) |
| 1614 | assert.Equal(t, []string{"http://localhost:3000/callback"}, got.Callbacks) |
| 1615 | }) |
| 1616 | |
| 1617 | t.Run("custom port is used", func(t *testing.T) { |
| 1618 | req := auth0.RequestParams{Callbacks: []string{sub}, AllowedLogoutURLs: []string{sub}} |
| 1619 | got := resolveRequestParams(req, "App", 5173) |
| 1620 | assert.Equal(t, []string{"http://localhost:5173/callback"}, got.Callbacks) |
| 1621 | assert.Equal(t, []string{"http://localhost:5173"}, got.AllowedLogoutURLs) |
| 1622 | }) |
| 1623 | |
| 1624 | t.Run("literal URLs are not replaced", func(t *testing.T) { |
| 1625 | req := auth0.RequestParams{ |
| 1626 | Callbacks: []string{"http://localhost:5173/callback"}, |
| 1627 | AllowedLogoutURLs: []string{"http://localhost:5173"}, |
| 1628 | } |
| 1629 | got := resolveRequestParams(req, "App", 5173) |
| 1630 | assert.Equal(t, []string{"http://localhost:5173/callback"}, got.Callbacks) |
| 1631 | assert.Equal(t, []string{"http://localhost:5173"}, got.AllowedLogoutURLs) |
| 1632 | }) |
| 1633 | |
| 1634 | t.Run("non-DetectionSub name is preserved", func(t *testing.T) { |
| 1635 | req := auth0.RequestParams{Name: "literal-name"} |
| 1636 | got := resolveRequestParams(req, "OtherName", 3000) |
| 1637 | assert.Equal(t, "literal-name", got.Name) |
| 1638 | }) |
| 1639 | } |
| 1640 | |
| 1641 | // -- replaceDetectionSub --. |
| 1642 |
nothing calls this directly
no test coverage detected