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

Function TestConfig_SetDefaultAppIDForTenant

internal/config/config_test.go:641–684  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

639}
640
641func TestConfig_SetDefaultAppIDForTenant(t *testing.T) {
642 t.Run("it successfully saves a new default app id for the tenant", func(t *testing.T) {
643 tempFile := createTempConfigFile(t, []byte(`{
644 "install_id": "3998b053-dd7f-4bfe-bb10-c4f3a96a0180",
645 "default_tenant": "auth0-cli.eu.auth0.com",
646 "tenants": {
647 "auth0-cli.eu.auth0.com": {
648 "name": "auth0-cli",
649 "domain": "auth0-cli.eu.auth0.com",
650 "access_token": "eyfSaswe",
651 "expires_at": "2023-04-18T11:18:07.998809Z",
652 "client_id": "secret"
653 }
654 }
655 }`))
656
657 expectedConfig := `{
658 "install_id": "3998b053-dd7f-4bfe-bb10-c4f3a96a0180",
659 "default_tenant": "auth0-cli.eu.auth0.com",
660 "tenants": {
661 "auth0-cli.eu.auth0.com": {
662 "name": "auth0-cli",
663 "domain": "auth0-cli.eu.auth0.com",
664 "access_token": "eyfSaswe",
665 "expires_at": "2023-04-18T11:18:07.998809Z",
666 "default_app_id": "appID123456",
667 "client_id": "secret"
668 }
669 }
670}`
671
672 config := &Config{path: tempFile}
673 err := config.SetDefaultAppIDForTenant("auth0-cli.eu.auth0.com", "appID123456")
674 assert.NoError(t, err)
675 assertConfigFileMatches(t, config.path, expectedConfig)
676 })
677
678 t.Run("it throws an error if there's an issue with the config file", func(t *testing.T) {
679 config := &Config{path: "i-dont-exist.json"}
680
681 err := config.SetDefaultAppIDForTenant("tenant", "appID123456")
682 assert.EqualError(t, err, "config.json file is missing")
683 })
684}
685
686func TestConfig_IsLoggedInWithTenant(t *testing.T) {
687 t.Run("it returns true when there is a tenant in the config and its access token is valid", func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

createTempConfigFileFunction · 0.85
assertConfigFileMatchesFunction · 0.85

Tested by

no test coverage detected