def METHOD_NAME(cli, hosts_file, hostname, setup, service):
    setup(hosts_file)
    # When the user logs in with a token
    token = "sample_token"
    result = cli.auth.login(token, f"--hosts-file={hosts_file}", f"--hostname={hostname}", "--protocol=http")
    # Then the command succeeds
    assert result.exit_code == 0, result.stdout
    assert result.stdout.strip() == f"✔️ Logged in into {hostname} as {USERNAME}"
    assert_token(hostname, hosts_file, token)