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

Function TestConfig_SetDefaultTenant

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

Source from the content-addressed store, hash-verified

554}
555
556func TestConfig_SetDefaultTenant(t *testing.T) {
557 t.Run("it can successfully save a new tenant default", func(t *testing.T) {
558 tempFile := createTempConfigFile(t, []byte(`{
559 "install_id": "3998b053-dd7f-4bfe-bb10-c4f3a96a0180",
560 "default_tenant": "auth0-cli.eu.auth0.com",
561 "tenants": {
562 "auth0-cli.eu.auth0.com": {
563 "name": "auth0-cli",
564 "domain": "auth0-cli.eu.auth0.com",
565 "access_token": "eyfSaswe",
566 "expires_at": "2023-04-18T11:18:07.998809Z",
567 "client_id": "secret"
568 },
569 "auth0-mega-cli.eu.auth0.com": {
570 "name": "auth0-mega-cli",
571 "domain": "auth0-mega-cli.eu.auth0.com",
572 "access_token": "eyfSaswe",
573 "expires_at": "2023-04-18T11:18:07.998809Z",
574 "client_id": "secret"
575 }
576 }
577 }`))
578
579 expectedConfig := `{
580 "install_id": "3998b053-dd7f-4bfe-bb10-c4f3a96a0180",
581 "default_tenant": "auth0-mega-cli.eu.auth0.com",
582 "tenants": {
583 "auth0-cli.eu.auth0.com": {
584 "name": "auth0-cli",
585 "domain": "auth0-cli.eu.auth0.com",
586 "access_token": "eyfSaswe",
587 "expires_at": "2023-04-18T11:18:07.998809Z",
588 "client_id": "secret"
589 },
590 "auth0-mega-cli.eu.auth0.com": {
591 "name": "auth0-mega-cli",
592 "domain": "auth0-mega-cli.eu.auth0.com",
593 "access_token": "eyfSaswe",
594 "expires_at": "2023-04-18T11:18:07.998809Z",
595 "client_id": "secret"
596 }
597 }
598}`
599
600 config := &Config{path: tempFile}
601 err := config.SetDefaultTenant("auth0-mega-cli.eu.auth0.com")
602 assert.NoError(t, err)
603 assertConfigFileMatches(t, config.path, expectedConfig)
604 })
605
606 t.Run("it fails to save a new tenant default if it doesn't exist", func(t *testing.T) {
607 tempFile := createTempConfigFile(t, []byte(`{
608 "install_id": "3998b053-dd7f-4bfe-bb10-c4f3a96a0180",
609 "default_tenant": "auth0-cli.eu.auth0.com",
610 "tenants": {
611 "auth0-cli.eu.auth0.com": {
612 "name": "auth0-cli",
613 "domain": "auth0-cli.eu.auth0.com",

Callers

nothing calls this directly

Calls 3

SetDefaultTenantMethod · 0.95
createTempConfigFileFunction · 0.85
assertConfigFileMatchesFunction · 0.85

Tested by

no test coverage detected