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

Function testLoginCmd

internal/cli/test.go:109–202  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

107}
108
109func testLoginCmd(cli *cli) *cobra.Command {
110 var inputs testCmdInputs
111
112 cmd := &cobra.Command{
113 Use: "login",
114 Args: cobra.MaximumNArgs(1),
115 Short: "Try out your tenant's Universal Login experience",
116 Long: "Try out your tenant's Universal Login experience in a browser.",
117 Example: ` auth0 test login
118 auth0 test login <client-id>
119 auth0 test login <client-id> --connection-name <connection-name>
120 auth0 test login <client-id> --connection-name <connection-name> --identifier <api-identifier>
121 auth0 test login <client-id> --connection-name <connection-name> --identifier <api-identifier> --organization <org-id>
122 auth0 test login <client-id> --connection-name <connection-name> --identifier <api-identifier> --domain <domain> --params "foo=bar"
123 auth0 test login <client-id> --connection-name <connection-name> --identifier <api-identifier> --domain <domain> --scopes <scope1,scope2>
124 auth0 test login <client-id> -c <connection-name> -a <api-identifier> -d <domain> -s <scope1,scope2> --force
125 auth0 test login <client-id> -c <connection-name> -a <api-identifier> -d <domain> -s <scope1,scope2> --json
126 auth0 test login <client-id> -c <connection-name> -a <api-identifier> -d <domain> -s <scope1,scope2> --json-compact
127 auth0 test login <client-id> -c <connection-name> -a <api-identifier> -d <domain> -o <org-id> -s <scope1,scope2> -p "foo=bar" -p "bazz=buzz" --json
128 auth0 test login <client-id> -c <connection-name> -a <api-identifier> -d <domain> -o <org-id> -s <scope1,scope2> -p "foo=bar","bazz=buzz" --json
129 auth0 test login <client-id> -c <connection-name> -a <api-identifier> -d <domain> -s <scope1,scope2> --force --json`,
130 RunE: func(cmd *cobra.Command, args []string) error {
131 client, err := selectClientToUseForTestsAndValidateExistence(cli, cmd, args, &inputs)
132 if err != nil {
133 return err
134 }
135
136 if client.GetAppType() == appTypeNonInteractive {
137 return fmt.Errorf(
138 "cannot test the Universal Login with a %s application.\n\n"+
139 "Run 'auth0 test token %s' to fetch an access token instead",
140 ansi.Bold("Machine to Machine"),
141 client.GetClientID(),
142 )
143 }
144
145 err = testDomain.Pick(cmd, &inputs.CustomDomain, cli.customDomainPickerOptions)
146 if err != nil && err != errNoCustomDomains {
147 return err
148 }
149
150 if proceed := runLoginFlowPreflightChecks(cli, client); !proceed {
151 return nil
152 }
153
154 if inputs.Organization != "" {
155 if inputs.CustomParams != nil {
156 inputs.CustomParams["organization"] = inputs.Organization
157 } else {
158 inputs.CustomParams = map[string]string{"organization": inputs.Organization}
159 }
160 }
161
162 tokenResponse, err := runLoginFlow(
163 cmd.Context(),
164 cli,
165 client,
166 inputs.ConnectionName,

Callers 1

testCmdFunction · 0.85

Calls 13

BoldFunction · 0.92
SpinnerFunction · 0.92
FetchUserInfoFunction · 0.92
runLoginFlowFunction · 0.85
resourceUsageTemplateFunction · 0.85
ErrorfMethod · 0.80
TestLoginMethod · 0.80
RegisterStringMethod · 0.80
RegisterStringSliceMethod · 0.80
RegisterStringMapMethod · 0.80

Tested by

no test coverage detected