(cli *cli)
| 107 | } |
| 108 | |
| 109 | func 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, |
no test coverage detected