failproofai 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +44 -44
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page/build-manifest.json +6 -6
- package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js +2 -3
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +2 -2
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/build-manifest.json +6 -6
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js +3 -4
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +6 -6
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +6 -6
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/audit/invite/route.js +3 -4
- package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/run/route.js +22 -23
- package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/status/route.js +2 -3
- package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js +4 -5
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js +4 -5
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/logout/route.js +4 -5
- package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/status/route.js +3 -4
- package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js +2 -3
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page/build-manifest.json +6 -6
- package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/audit/page.js +5 -6
- package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +6 -6
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +5 -5
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +6 -6
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page/build-manifest.json +6 -6
- package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/page.js +4 -5
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/policies/page/build-manifest.json +6 -6
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
- package/.next/standalone/.next/server/app/policies/page.js +4 -5
- package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page/build-manifest.json +6 -6
- package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js +20 -21
- package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/build-manifest.json +6 -6
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +8 -9
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page/build-manifest.json +6 -6
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js +6 -7
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/page/build-manifest.json +6 -6
- package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +8 -8
- package/.next/standalone/.next/server/app/settings/page.js +3 -4
- package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__1a2d0ewycsp6k._.js → [externals]__0h0p9dmv_e7r7._.js} +2 -2
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__1am_1tz0o0aqz._.js → [externals]__1_407huhlmj1m._.js} +2 -2
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__031qp1lkow_kc._.js → [externals]__1rlxpymm37wel._.js} +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__03s1za0hn71yp._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__048f1wnr8pysf._.js +63 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__07a0sa6fuw5_b._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0l-oi4gdtmlo5._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0spt0kv8azrpl._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0yvyp5b7jmlc4._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__145vo_drnuvas._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1lh8c0mmhdrbj._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1oclamblhzhrf._.js +7 -7
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1qjnp3fa0e5g3._.js +3 -0
- package/.next/standalone/.next/server/chunks/[turbopack]_runtime.js +7 -9
- package/.next/standalone/.next/server/chunks/_02sa8fcu9_9xo._.js +1 -1
- package/.next/standalone/.next/server/chunks/_09dz7xva4ce_2._.js +18 -18
- package/.next/standalone/.next/server/chunks/_0hf5q4xzyg40j._.js +1 -1
- package/.next/standalone/.next/server/chunks/_0tovk6q0miud6._.js +1 -1
- package/.next/standalone/.next/server/chunks/_0trp3ycqv17cl._.js +1 -1
- package/.next/standalone/.next/server/chunks/_1-2owkp-1_987._.js +1 -1
- package/.next/standalone/.next/server/chunks/_13ltj8a9z92o8._.js +1 -1
- package/.next/standalone/.next/server/chunks/_15k37au70vjvg._.js +1 -1
- package/.next/standalone/.next/server/chunks/_18rfu4__wjhwb._.js +1 -1
- package/.next/standalone/.next/server/chunks/_19011-u44143j._.js +1 -1
- package/.next/standalone/.next/server/chunks/_1ek68lnh2daur._.js +2 -2
- package/.next/standalone/.next/server/chunks/_1fz8m31sndkcu._.js +1 -1
- package/.next/standalone/.next/server/chunks/_1ogwigfb0163w._.js +1 -1
- package/.next/standalone/.next/server/chunks/_1vslkoe35wok6._.js +1 -1
- package/.next/standalone/.next/server/chunks/lib_11qmqmccehybz._.js +1 -1
- package/.next/standalone/.next/server/chunks/lib_1sezqnatvr8j-._.js +1 -1
- package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_01r25oigsgz07._.js +1 -2
- package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_09z9-p77cu37y._.js +1 -2
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4vkpxxu7._.js +1 -1
- package/.next/standalone/.next/server/chunks/src_hooks_0_em82s16zfym._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[externals]__0ilfh9mfnzsth._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/[externals]__0ohnuzsaozaca._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__097i34ct1o88x._.js → [externals]__12qr51qgrrt6o._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__021vebe-4il8s._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__08ch3staq3ejw._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0bigvy9xmv2ka._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0evgy902m9h5e._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ezoipo-r7_5k._.js +14 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0h1jw32uvrhh0._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0h86bl2qf0k_o._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0pia5h3p8re4c._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__10v5cyxvj64j4._.js → [root-of-the-server]__0tfnj3v_mp6rv._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1-9s1nsw-5q8o._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1-ey9fgesfbc0._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__15bi9em2xe0x2._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__15usvs-ms-0hf._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__16gb3_92zvk5x._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1avi2kypusyb_._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__20dt376-socef._.js → [root-of-the-server]__1e00l_e_8r_-g._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1mc9-zlnh656_._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1ob2uzmms1adf._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1r7drlqli-ado._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0ed1zh4scn7-k._.js → [root-of-the-server]__1tq3x9i_3_860._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1utel1l1-u64v._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1vofkb2oq7p7e._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1vxwetblyf8vp._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1xwr4hi-on27i._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__2158020r_amn9._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[turbopack]_runtime.js +7 -9
- package/.next/standalone/.next/server/chunks/ssr/_0-f9uotv7v2n9._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_00e4_rvim31u_._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0bseae9u7g98r._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0eoura3_9gjb-._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_0kqw2_f1ywmpo._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0mouhaflye1ro._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0ouu886szh6yj._.js +10 -10
- package/.next/standalone/.next/server/chunks/ssr/_0p1cb69sml__f._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/_0pedwblqdoh58._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0tfqha481f033._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_1_ozgifqv1ssi._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1a516zcgtqius._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1ddpc5gj57uuf._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1djqs9i27e4kg._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1ew6ra24vt-ij._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1or8gixmrpv5i._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1s8zk-upxzp00._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1u9tpla2o6utw._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1v4_ul3sj2lq_._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1y3xzro8ca8t6._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_20hn4gn87nsjc._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo5_vm5f.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/app_087bt9wus25zs._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_0trz6ik19xz5_._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_1fvisnppn1unv._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_209u41o446my6._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_actions_get-scheduled-audit_ts_0ei9snixb5fd-._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_audit_0hku_y73ischw._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47q0xq5w._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x33jqb6._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpcz0uxur._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_settings_02tf1h47jmhhd._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/lib_16jvhmthj_k3a._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_05vgn62--7c5e._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_0dad4au22rq0p._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_0gxlxpuufujz9._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/node_modules_0ptcnmeaxvd_a._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_html-to-image_es_index_1cmkmhnty0-x7.js → node_modules_html-to-image_es_index_0r9i9nq3-ei-l.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_0bz67659f5z-3._.js +4 -4
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_0-amwqbrge23p._.js +6 -0
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_0ocrceo0c9psx._.js +4 -4
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_1alv566ojmz5j._.js +4 -4
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_1et9oq9q9-y3v._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_1khq67j4vo9y4._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_client_components_0wpq8j32_ibz4._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_shared_lib_0ftnv26hg1lry._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_0dagmbznysrc2._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_11bnuznb72p7z._.js +1 -2
- package/.next/standalone/.next/server/chunks/ssr/package_json_[json]_cjs_013tntikdft59._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_0-q0ummbuhlg5._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_06kzv9ddabn3_._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_0agdmptetetdt._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_0g194syq7r7ql._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_0mdwgjisv4fub._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_1cv9_c4l1tzrm._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_1kx9e0dx_1-8o._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +44 -44
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/preview-props.json +3 -3
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +23 -23
- package/.next/standalone/.next/static/chunks/0tiuj32d-qcy3.js +1 -0
- package/.next/standalone/.next/static/chunks/0ztuix-ip2oiv.js +1 -0
- package/.next/standalone/.next/static/chunks/{40g_e46c1-j4k.js → 107jrtkeylnrv.js} +1 -1
- package/.next/standalone/.next/static/chunks/110hwwc6agsr8.js +1 -0
- package/.next/standalone/.next/static/chunks/19e9khxgv8fb8.js +1 -0
- package/.next/standalone/.next/static/chunks/1dudxmlwx2n3q.js +1 -0
- package/.next/standalone/.next/static/chunks/1i9zuw01f0ogt.js +22 -0
- package/.next/standalone/.next/static/chunks/2codb6nb412m9.js +1 -0
- package/.next/standalone/.next/static/chunks/2hqfk_jgesiw2.js +1 -0
- package/.next/standalone/.next/static/chunks/2k6xp6kdy7lmd.js +1 -0
- package/.next/standalone/.next/static/chunks/2maurwweshrsj.js +1 -0
- package/.next/standalone/.next/static/chunks/2wh64znsc_mo2.js +1 -0
- package/.next/standalone/.next/static/chunks/2wye36b3mbzpa.js +31 -0
- package/.next/standalone/.next/static/chunks/{0mm-e5t9denbu.js → 2zlfhyqvlvf7o.js} +1 -1
- package/.next/standalone/.next/static/chunks/3hk5y4kny2ktd.js +1 -0
- package/.next/standalone/.next/static/chunks/3i_9ugyh1q1o1.js +1 -0
- package/.next/standalone/.next/static/chunks/3o30fiw7llng3.js +1 -0
- package/.next/standalone/.next/static/chunks/3v49ogp389dun.js +1 -0
- package/.next/standalone/.next/static/chunks/41ujrab732qi3.css +2 -0
- package/.next/standalone/.next/static/chunks/435eshlryosz1.js +1 -0
- package/.next/standalone/.next/static/chunks/436g_rqa42mr7.js +1 -0
- package/.next/standalone/.next/static/chunks/436nql0jk__xy.js +1 -0
- package/.next/standalone/.next/static/chunks/{turbopack-3-ry682tkyiqk.js → turbopack-2u1d16houkiyo.js} +1 -1
- package/.next/standalone/SECURITY.md +19 -4
- package/.next/standalone/fp-cloud-cli/CHANGELOG.md +13 -3
- package/.next/standalone/fp-cloud-cli/README.md +14 -7
- package/.next/standalone/fp-cloud-cli/fp_cli/_version.py +1 -1
- package/.next/standalone/fp-cloud-cli/fp_cli/app.py +2 -8
- package/.next/standalone/fp-cloud-cli/fp_cli/auth.py +325 -3
- package/.next/standalone/fp-cloud-cli/fp_cli/cloud_output.py +3 -3
- package/.next/standalone/fp-cloud-cli/fp_cli/commands/account_cmds.py +1 -11
- package/.next/standalone/fp-cloud-cli/fp_cli/commands/auth_cmds.py +218 -51
- package/.next/standalone/fp-cloud-cli/fp_cli/commands/orgs_cmds.py +1 -1
- package/.next/standalone/fp-cloud-cli/fp_cli/output.py +112 -135
- package/.next/standalone/fp-cloud-cli/fp_cli/permissions.py +10 -1
- package/.next/standalone/fp-cloud-cli/fp_cli/select.py +85 -6
- package/.next/standalone/fp-cloud-cli/fp_cli/theme.py +21 -21
- package/.next/standalone/fp-cloud-cli/pyproject.toml +1 -1
- package/.next/standalone/fp-cloud-cli/skill/SKILL.md +4 -4
- package/.next/standalone/fp-cloud-cli/skill/references/commands.md +4 -4
- package/.next/standalone/fp-cloud-cli/tests/fake_cloud_smoke.py +2 -2
- package/.next/standalone/fp-cloud-cli/tests/test_browser_login.py +943 -0
- package/.next/standalone/fp-cloud-cli/tests/test_cloud_account.py +0 -2
- package/.next/standalone/fp-cloud-cli/tests/test_cloud_agent.py +4 -8
- package/.next/standalone/fp-cloud-cli/tests/test_cloud_human_views.py +0 -4
- package/.next/standalone/fp-cloud-cli/tests/test_commands.py +3 -3
- package/.next/standalone/fp-cloud-cli/tests/test_dashboards_agent.py +3 -3
- package/.next/standalone/fp-cloud-cli/tests/test_facets.py +1 -1
- package/.next/standalone/fp-cloud-cli/tests/test_keys_queries.py +19 -2
- package/.next/standalone/fp-cloud-cli/tests/test_operator.py +1 -1
- package/.next/standalone/fp-cloud-cli/tests/test_orgs.py +1 -1
- package/.next/standalone/fp-cloud-cli/tests/test_output.py +19 -19
- package/.next/standalone/fp-cloud-cli/tests/test_round4_behaviour.py +3 -2
- package/.next/standalone/fp-cloud-cli/tests/test_screen_language.py +86 -25
- package/.next/standalone/fp-cloud-cli/tests/test_whoami.py +1 -1
- package/.next/standalone/fp-cloud-cli/uv.lock +200 -13
- package/.next/standalone/hermes-plugin/plugin.yaml +1 -1
- package/.next/standalone/node_modules/@next/env/package.json +1 -1
- package/.next/standalone/node_modules/next/dist/build/swc/index.js +1 -1
- package/.next/standalone/node_modules/next/dist/compiled/fast-jwt/index.js +3 -0
- package/.next/standalone/node_modules/next/dist/compiled/fast-jwt/package.json +1 -0
- package/.next/standalone/node_modules/next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js +23 -23
- package/.next/standalone/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.prod.js +23 -23
- package/.next/standalone/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +1 -1
- package/.next/standalone/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +7 -7
- package/.next/standalone/node_modules/next/dist/lib/patch-incorrect-lockfile.js +3 -3
- package/.next/standalone/node_modules/next/dist/server/api-utils/node/api-resolver.js +8 -5
- package/.next/standalone/node_modules/next/dist/server/api-utils/node/try-get-preview-data.js +8 -2
- package/.next/standalone/node_modules/next/dist/server/app-render/app-render.js +52 -14
- package/.next/standalone/node_modules/next/dist/server/app-render/async-local-storage.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/app-render/get-script-nonce-from-header.js +19 -3
- package/.next/standalone/node_modules/next/dist/server/app-render/turbopack-bootstrap-script.js +50 -0
- package/.next/standalone/node_modules/next/dist/server/base-server.js +8 -0
- package/.next/standalone/node_modules/next/dist/server/config.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +59 -10
- package/.next/standalone/node_modules/next/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/dev/turbopack-utils.js +15 -0
- package/.next/standalone/node_modules/next/dist/server/image-optimizer/detect-content-type.js +24 -20
- package/.next/standalone/node_modules/next/dist/server/lib/app-info-log.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/lib/dev-bundler-service.js +3 -0
- package/.next/standalone/node_modules/next/dist/server/lib/router-server.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/lib/start-server.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/lib/trace/tracer.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/next-server.js +10 -2
- package/.next/standalone/node_modules/next/dist/server/render.js +2 -2
- package/.next/standalone/node_modules/next/dist/server/route-modules/app-page/parse-request-headers.js +1 -2
- package/.next/standalone/node_modules/next/dist/server/send-response.js +12 -0
- package/.next/standalone/node_modules/next/dist/server/use-cache/use-cache-wrapper.js +69 -6
- package/.next/standalone/node_modules/next/dist/server/web/adapter.js +5 -1
- package/.next/standalone/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
- package/.next/standalone/node_modules/next/dist/telemetry/events/swc-load-failure.js +1 -1
- package/.next/standalone/node_modules/next/dist/telemetry/events/version.js +2 -2
- package/.next/standalone/node_modules/next/package.json +10 -10
- package/.next/standalone/package.json +11 -11
- package/.next/standalone/sdk/python/skill/SKILL.md +5 -0
- package/.next/standalone/sdk/python/uv.lock +79 -47
- package/.next/standalone/sdk/typescript/CHANGELOG.md +48 -5
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/package-lock.json +0 -9
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/package.json +2 -1
- package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/package-lock.json +72 -44
- package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/package.json +2 -1
- package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/package-lock.json +72 -44
- package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/package.json +3 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/package-lock.json +18 -332
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/package.json +4 -2
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/package-lock.json +925 -296
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/package.json +3 -8
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/package-lock.json +279 -277
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/package.json +2 -2
- package/.next/standalone/server.js +1 -1
- package/dist/cli.mjs +22 -12
- package/dist/worker.mjs +1 -1
- package/hermes-plugin/plugin.yaml +1 -1
- package/package.json +11 -11
- package/src/hooks/delivery-health.ts +11 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__038kwryp970nh._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__08atcie7jzswm._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0car70pylmvor._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1j6kfp0vzu5rw._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1l0ayum_hqqsw._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1o9rznwc0w7og._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1v1-l-83czzsr._.js +0 -63
- package/.next/standalone/.next/server/chunks/node_modules_@opentelemetry_api_build_esm_index_0oo58a7rymoxh.js +0 -3
- package/.next/standalone/.next/server/chunks/node_modules_@opentelemetry_api_build_esm_index_1jp9ij0_ddtgk.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__075uro8t92s0_._.js +0 -14
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0alpzjn3450sr._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0aup10z2o8zc1._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0bioghlkjf7s7._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0nhm28v58ty9z._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0vse4qi496ol-._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__190xwrr5zrfi3._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1guwlpkyurdn9._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1jq2bh84rafc7._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1k96jctukf65_._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1sj-wn2jp6va5._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/_100nvr7rei3us._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules_@opentelemetry_api_build_esm_index_0ntwr8lzj6p2i.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_0janj0i6dqko7._.js +0 -6
- package/.next/standalone/.next/static/chunks/0rucj5pu307i4.js +0 -1
- package/.next/standalone/.next/static/chunks/1-0se0uwja_ny.js +0 -1
- package/.next/standalone/.next/static/chunks/1024g0jaymm46.js +0 -1
- package/.next/standalone/.next/static/chunks/165ezyyx0j1ft.js +0 -22
- package/.next/standalone/.next/static/chunks/173vw1xs-5m5g.js +0 -1
- package/.next/standalone/.next/static/chunks/20cme7d6wv6md.js +0 -1
- package/.next/standalone/.next/static/chunks/26c4gmdpsthv6.css +0 -2
- package/.next/standalone/.next/static/chunks/2_sj5ssr_m_wm.js +0 -1
- package/.next/standalone/.next/static/chunks/2mz-k_jt_76xt.js +0 -1
- package/.next/standalone/.next/static/chunks/2ojf3r8g4tn7s.js +0 -1
- package/.next/standalone/.next/static/chunks/2tjfp9dirxnku.js +0 -1
- package/.next/standalone/.next/static/chunks/2u1m0f-wnhz44.js +0 -1
- package/.next/standalone/.next/static/chunks/2ytnb83xmjn3u.js +0 -1
- package/.next/standalone/.next/static/chunks/2zyrjasvbmwpq.js +0 -1
- package/.next/standalone/.next/static/chunks/31fan-ze541d1.js +0 -1
- package/.next/standalone/.next/static/chunks/32s3y34p0t2pe.js +0 -1
- package/.next/standalone/.next/static/chunks/36re0fegaocq-.js +0 -1
- package/.next/standalone/.next/static/chunks/3fhk60ouw_ae6.js +0 -1
- package/.next/standalone/.next/static/chunks/3xgxl1s_in776.js +0 -31
- package/.next/standalone/.next/static/chunks/44yz8zx53euy1.js +0 -1
- package/.next/standalone/node_modules/next/dist/compiled/jsonwebtoken/index.js +0 -11
- package/.next/standalone/node_modules/next/dist/compiled/jsonwebtoken/package.json +0 -1
- package/.next/standalone/node_modules/next/dist/lib/semver-noop.js +0 -18
- /package/.next/standalone/.next/static/{4MgI0mZP1iVhhocpUivMm → -iBiSmrLiylRKLAg77zlQ}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{4MgI0mZP1iVhhocpUivMm → -iBiSmrLiylRKLAg77zlQ}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{4MgI0mZP1iVhhocpUivMm → -iBiSmrLiylRKLAg77zlQ}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,943 @@
|
|
|
1
|
+
"""`fp login` from a browser: the client half of `/api/auth/cli/*`, and the plain flow.
|
|
2
|
+
|
|
3
|
+
The box itself needs a real terminal, so `__tests__/e2e/layout/fp-login.sh` drives it
|
|
4
|
+
through a pty against a real stack. What is pinned here is everything that decides
|
|
5
|
+
what a server's answer means, because each mistake there is silent: a Cloud that drops
|
|
6
|
+
`kind` hands back a machine key, and a poll that gives up reads as a person's "no".
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import io
|
|
12
|
+
import json
|
|
13
|
+
import time
|
|
14
|
+
from types import SimpleNamespace
|
|
15
|
+
|
|
16
|
+
import httpx
|
|
17
|
+
import pytest
|
|
18
|
+
import respx
|
|
19
|
+
from rich.console import Console
|
|
20
|
+
from rich.live import Live
|
|
21
|
+
|
|
22
|
+
from fp_cli import auth, config, output
|
|
23
|
+
from fp_cli import select as selectmod
|
|
24
|
+
from fp_cli._context import AppState
|
|
25
|
+
from fp_cli.app import app
|
|
26
|
+
from fp_cli.commands import auth_cmds
|
|
27
|
+
from fp_cli.errors import ApiError, AuthError, NetworkError
|
|
28
|
+
|
|
29
|
+
BASE = "http://dash.test"
|
|
30
|
+
LINK = f"{BASE}/cli/authorize?r=abc"
|
|
31
|
+
STARTED = {
|
|
32
|
+
"verification_url": LINK,
|
|
33
|
+
"poll_secret": "POLL",
|
|
34
|
+
"expires_in": 600,
|
|
35
|
+
"interval": 2,
|
|
36
|
+
"kind": "session",
|
|
37
|
+
}
|
|
38
|
+
SESSION = {
|
|
39
|
+
"id": "u1",
|
|
40
|
+
"email": "me@test",
|
|
41
|
+
"is_instance_admin": False,
|
|
42
|
+
"memberships": [
|
|
43
|
+
{"org_id": "o1", "org_slug": "acme", "org_name": "Acme", "permissions": [], "permission_set": "admin"}
|
|
44
|
+
],
|
|
45
|
+
}
|
|
46
|
+
CLAIMED = {"session_token": "tok-browser", "expires_in_secs": 3600, "user": {"id": "u1", "email": "me@test"}}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _start(**over):
|
|
50
|
+
return httpx.Response(over.pop("status", 201), json={**STARTED, **over})
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# --- start ------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@respx.mock
|
|
57
|
+
def test_start_asks_for_a_session_and_names_the_machine():
|
|
58
|
+
route = respx.post(f"{BASE}/api/auth/cli/start").mock(return_value=_start())
|
|
59
|
+
login = auth.start_browser_login(BASE)
|
|
60
|
+
assert login == auth.BrowserLogin(LINK, "POLL", 600, 2)
|
|
61
|
+
sent = json.loads(route.calls[0].request.content)
|
|
62
|
+
assert sent["kind"] == "session"
|
|
63
|
+
assert sent["machine_label"]
|
|
64
|
+
assert sent["cli_version"].startswith("fp ")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@respx.mock
|
|
68
|
+
@pytest.mark.parametrize(
|
|
69
|
+
"response",
|
|
70
|
+
[
|
|
71
|
+
httpx.Response(404),
|
|
72
|
+
httpx.Response(302, headers={"location": f"{BASE}/login"}),
|
|
73
|
+
httpx.Response(200, text="<html>a page, not this API</html>"),
|
|
74
|
+
# A Cloud with `failproofai config`'s login but not this: it dropped `kind`,
|
|
75
|
+
# and approving this request would end in a machine key.
|
|
76
|
+
httpx.Response(201, json={k: v for k, v in STARTED.items() if k != "kind"}),
|
|
77
|
+
httpx.Response(201, json={**STARTED, "kind": "machine_key"}),
|
|
78
|
+
httpx.Response(201, json={"kind": "session"}),
|
|
79
|
+
httpx.Response(201, json={**STARTED, "poll_secret": ""}),
|
|
80
|
+
],
|
|
81
|
+
)
|
|
82
|
+
def test_a_cloud_that_cannot_do_this_reads_as_unsupported(response):
|
|
83
|
+
respx.post(f"{BASE}/api/auth/cli/start").mock(return_value=response)
|
|
84
|
+
assert auth.start_browser_login(BASE) is None
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@respx.mock
|
|
88
|
+
@pytest.mark.parametrize(
|
|
89
|
+
"url",
|
|
90
|
+
[
|
|
91
|
+
"file:///etc/passwd",
|
|
92
|
+
"javascript:alert(1)",
|
|
93
|
+
"ssh://dash.test",
|
|
94
|
+
"http://",
|
|
95
|
+
"https://:443/cli/authorize?r=abc",
|
|
96
|
+
"https://dash.test:99999/cli/authorize?r=abc",
|
|
97
|
+
"https://dash.test:0/cli/authorize?r=abc",
|
|
98
|
+
"https://[broken/cli/authorize?r=abc",
|
|
99
|
+
f"{LINK}\x1b]0;pwned\x07",
|
|
100
|
+
f"{LINK} --and-more",
|
|
101
|
+
None,
|
|
102
|
+
],
|
|
103
|
+
)
|
|
104
|
+
def test_only_a_plain_http_link_is_ever_printed_or_opened(url):
|
|
105
|
+
respx.post(f"{BASE}/api/auth/cli/start").mock(return_value=_start(verification_url=url))
|
|
106
|
+
assert auth.start_browser_login(BASE) is None
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@respx.mock
|
|
110
|
+
def test_start_failures_say_what_kind_of_failure_they_are():
|
|
111
|
+
route = respx.post(f"{BASE}/api/auth/cli/start")
|
|
112
|
+
route.mock(return_value=httpx.Response(429, json={"error": "rate_limited"}))
|
|
113
|
+
with pytest.raises(ApiError, match="Too many"):
|
|
114
|
+
auth.start_browser_login(BASE)
|
|
115
|
+
route.mock(return_value=httpx.Response(502, json={"error": "upstream unreachable"}))
|
|
116
|
+
with pytest.raises(NetworkError):
|
|
117
|
+
auth.start_browser_login(BASE)
|
|
118
|
+
route.mock(return_value=httpx.Response(422, json={"error": "machine_label_required"}))
|
|
119
|
+
with pytest.raises(ApiError, match="HTTP 422"):
|
|
120
|
+
auth.start_browser_login(BASE)
|
|
121
|
+
route.mock(side_effect=httpx.ConnectError("no route"))
|
|
122
|
+
with pytest.raises(NetworkError):
|
|
123
|
+
auth.start_browser_login(BASE)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@respx.mock
|
|
127
|
+
def test_a_servers_numbers_are_kept_to_a_range_this_client_can_live_with():
|
|
128
|
+
route = respx.post(f"{BASE}/api/auth/cli/start")
|
|
129
|
+
route.mock(return_value=_start(expires_in=10**9, interval=0.001))
|
|
130
|
+
login = auth.start_browser_login(BASE)
|
|
131
|
+
assert (login.expires_in, login.interval) == (3600, 1)
|
|
132
|
+
route.mock(return_value=_start(expires_in="soon", interval=True))
|
|
133
|
+
login = auth.start_browser_login(BASE)
|
|
134
|
+
assert (login.expires_in, login.interval) == (600, 2)
|
|
135
|
+
# JSON integers have no size limit, and a float can be infinite.
|
|
136
|
+
route.mock(return_value=_start(expires_in=10**400, interval=10**400))
|
|
137
|
+
login = auth.start_browser_login(BASE)
|
|
138
|
+
assert (login.expires_in, login.interval) == (3600, 30)
|
|
139
|
+
route.mock(return_value=httpx.Response(201, text=json.dumps(STARTED).replace("600", "Infinity")))
|
|
140
|
+
assert auth.start_browser_login(BASE).expires_in == 600
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
# --- poll -------------------------------------------------------------------
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
@respx.mock
|
|
147
|
+
@pytest.mark.parametrize(
|
|
148
|
+
"status", ["pending", "slow_down", "approved", "denied", "expired", "claimed"]
|
|
149
|
+
)
|
|
150
|
+
def test_poll_reports_each_status(status):
|
|
151
|
+
respx.post(f"{BASE}/api/auth/cli/poll").mock(return_value=httpx.Response(200, json={"status": status}))
|
|
152
|
+
assert auth.poll_browser_login(BASE, "POLL") == status
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@respx.mock
|
|
156
|
+
def test_poll_tells_unknown_from_try_again():
|
|
157
|
+
route = respx.post(f"{BASE}/api/auth/cli/poll")
|
|
158
|
+
route.mock(return_value=httpx.Response(404, json={"status": "unknown"}))
|
|
159
|
+
assert auth.poll_browser_login(BASE, "POLL") == "unknown"
|
|
160
|
+
route.mock(return_value=httpx.Response(200, json={"status": "something new"}))
|
|
161
|
+
assert auth.poll_browser_login(BASE, "POLL") == "unknown"
|
|
162
|
+
for answer in (httpx.Response(500), httpx.Response(200, text="not json")):
|
|
163
|
+
route.mock(return_value=answer)
|
|
164
|
+
with pytest.raises(NetworkError):
|
|
165
|
+
auth.poll_browser_login(BASE, "POLL")
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _quick(expires_in=60.0):
|
|
169
|
+
return auth.BrowserLogin(LINK, "POLL", expires_in, 0.0)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
@respx.mock
|
|
173
|
+
def test_waiting_carries_on_through_a_dropped_connection():
|
|
174
|
+
respx.post(f"{BASE}/api/auth/cli/poll").mock(
|
|
175
|
+
side_effect=[
|
|
176
|
+
httpx.Response(200, json={"status": "pending"}),
|
|
177
|
+
httpx.ConnectError("wifi went away"),
|
|
178
|
+
httpx.Response(500),
|
|
179
|
+
httpx.Response(200, json={"status": "slow_down"}),
|
|
180
|
+
httpx.Response(200, json={"status": "approved"}),
|
|
181
|
+
]
|
|
182
|
+
)
|
|
183
|
+
seen = []
|
|
184
|
+
# `slow_down` adds a second before the next poll: the tick is what passes it.
|
|
185
|
+
def tick(_left, offline):
|
|
186
|
+
seen.append(offline)
|
|
187
|
+
time.sleep(0.05)
|
|
188
|
+
|
|
189
|
+
assert auth.await_browser_approval(BASE, _quick(), tick=tick) == "approved"
|
|
190
|
+
assert True in seen, "a dropped connection is shown to the person"
|
|
191
|
+
assert seen[-1] is False, "and clears once the server answers"
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
@respx.mock
|
|
195
|
+
@pytest.mark.parametrize("final", ["denied", "expired", "claimed"])
|
|
196
|
+
def test_waiting_ends_on_any_final_answer(final):
|
|
197
|
+
respx.post(f"{BASE}/api/auth/cli/poll").mock(return_value=httpx.Response(200, json={"status": final}))
|
|
198
|
+
assert auth.await_browser_approval(BASE, _quick(), tick=lambda *_: None) == final
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@respx.mock
|
|
202
|
+
def test_waiting_gives_up_when_the_link_runs_out():
|
|
203
|
+
route = respx.post(f"{BASE}/api/auth/cli/poll")
|
|
204
|
+
assert auth.await_browser_approval(BASE, _quick(expires_in=0.0), tick=lambda *_: None) == "expired"
|
|
205
|
+
assert not route.called
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
@respx.mock
|
|
209
|
+
def test_coming_back_to_a_link_keeps_its_countdown():
|
|
210
|
+
# Tab away and back must not promise ten more minutes the server won't honour.
|
|
211
|
+
respx.post(f"{BASE}/api/auth/cli/poll").mock(return_value=httpx.Response(200, json={"status": "approved"}))
|
|
212
|
+
left = []
|
|
213
|
+
old = auth.BrowserLogin(LINK, "POLL", 60.0, 0.0, started=time.monotonic() - 50.0)
|
|
214
|
+
auth.await_browser_approval(BASE, old, tick=lambda seconds, _offline: left.append(seconds))
|
|
215
|
+
assert left and left[0] <= 10.0
|
|
216
|
+
gone = auth.BrowserLogin(LINK, "POLL", 60.0, 0.0, started=time.monotonic() - 61.0)
|
|
217
|
+
assert auth.await_browser_approval(BASE, gone, tick=lambda *_: None) == "expired"
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
# --- claim ------------------------------------------------------------------
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
@respx.mock
|
|
224
|
+
def test_claim_returns_the_session_in_the_shape_of_the_emailed_code():
|
|
225
|
+
respx.post(f"{BASE}/api/auth/cli/claim").mock(return_value=httpx.Response(201, json=CLAIMED))
|
|
226
|
+
assert auth.claim_browser_login(BASE, "POLL") == ("tok-browser", 3600, CLAIMED["user"])
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
@respx.mock
|
|
230
|
+
@pytest.mark.parametrize("lifetime,saved", [(10**400, 30 * 86400), (0, 86400), ("soon", 86400), (None, 86400)])
|
|
231
|
+
def test_a_servers_session_lifetime_cannot_crash_saving_it(home, lifetime, saved):
|
|
232
|
+
respx.post(f"{BASE}/api/auth/cli/claim").mock(
|
|
233
|
+
return_value=httpx.Response(201, json={**CLAIMED, "expires_in_secs": lifetime})
|
|
234
|
+
)
|
|
235
|
+
token, expires_in, user = auth.claim_browser_login(BASE, "POLL")
|
|
236
|
+
assert expires_in == saved
|
|
237
|
+
auth.persist_session(config.load_config(), BASE, token, expires_in, user)
|
|
238
|
+
assert config.load_config().session_token == "tok-browser"
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
@respx.mock
|
|
242
|
+
def test_claim_refuses_anything_but_a_session():
|
|
243
|
+
route = respx.post(f"{BASE}/api/auth/cli/claim")
|
|
244
|
+
# What a machine-key request would answer. Never saved as if it were a session.
|
|
245
|
+
route.mock(return_value=httpx.Response(201, json={"api_key": "KEY", "key_id": "k"}))
|
|
246
|
+
with pytest.raises(AuthError):
|
|
247
|
+
auth.claim_browser_login(BASE, "POLL")
|
|
248
|
+
for status in (403, 409, 410):
|
|
249
|
+
route.mock(return_value=httpx.Response(status, json={"error": "approval_revoked"}))
|
|
250
|
+
with pytest.raises(AuthError) as err:
|
|
251
|
+
auth.claim_browser_login(BASE, "POLL")
|
|
252
|
+
assert err.value.hint == "run fp login again"
|
|
253
|
+
route.mock(return_value=httpx.Response(500))
|
|
254
|
+
with pytest.raises(NetworkError):
|
|
255
|
+
auth.claim_browser_login(BASE, "POLL")
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
@respx.mock
|
|
259
|
+
@pytest.mark.parametrize(
|
|
260
|
+
"user",
|
|
261
|
+
[None, {}, {"id": "u1"}, {"email": "me@test"}, {"id": "u1", "email": ""}, {"id": "u1", "email": "\x1b\u200b"}, "me"],
|
|
262
|
+
)
|
|
263
|
+
def test_a_claim_with_no_identity_is_no_login(user):
|
|
264
|
+
# `persist_session` keeps the previous identity when a field is missing, so this
|
|
265
|
+
# would otherwise save the new session under whoever was signed in before.
|
|
266
|
+
respx.post(f"{BASE}/api/auth/cli/claim").mock(
|
|
267
|
+
return_value=httpx.Response(201, json={**CLAIMED, "user": user})
|
|
268
|
+
)
|
|
269
|
+
with pytest.raises(AuthError):
|
|
270
|
+
auth.claim_browser_login(BASE, "POLL")
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
@respx.mock
|
|
274
|
+
@pytest.mark.parametrize("token", ["☃☃☃", "abc\r\nx-evil: 1", "a b", "\x1b]0;x\x07", "x" * 5000, ""])
|
|
275
|
+
def test_a_token_no_later_request_could_carry_is_never_saved(token):
|
|
276
|
+
# Saved, every later command fails on it, and a non-ASCII one with a traceback.
|
|
277
|
+
respx.post(f"{BASE}/api/auth/cli/claim").mock(
|
|
278
|
+
return_value=httpx.Response(201, json={**CLAIMED, "session_token": token})
|
|
279
|
+
)
|
|
280
|
+
with pytest.raises(AuthError):
|
|
281
|
+
auth.claim_browser_login(BASE, "POLL")
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
@respx.mock
|
|
285
|
+
@pytest.mark.parametrize(
|
|
286
|
+
"hostname,label",
|
|
287
|
+
[("ho\udcffst", "ho?st"), ("\x01\x02", "unknown"), (" ", "unknown"), ("", "unknown"), ("a\x1b]0;x\x07b", "a]0;xb")],
|
|
288
|
+
ids=["not-utf8", "controls", "spaces", "empty", "escape"],
|
|
289
|
+
)
|
|
290
|
+
def test_any_hostname_still_starts_a_login(monkeypatch, hostname, label):
|
|
291
|
+
# JSON can't carry a surrogate, which is how Python hands back bytes that aren't UTF-8,
|
|
292
|
+
# and the server refuses a label with nothing left in it.
|
|
293
|
+
monkeypatch.setattr(auth.socket, "gethostname", lambda: hostname)
|
|
294
|
+
route = respx.post(f"{BASE}/api/auth/cli/start").mock(return_value=_start())
|
|
295
|
+
assert auth.start_browser_login(BASE) is not None
|
|
296
|
+
assert json.loads(route.calls[0].request.content)["machine_label"] == label
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
@respx.mock
|
|
300
|
+
def test_what_the_server_says_about_the_person_cannot_drive_the_terminal():
|
|
301
|
+
evil = "me\x1b]0;pwned\x07@test\x1b[2J"
|
|
302
|
+
respx.post(f"{BASE}/api/auth/cli/claim").mock(
|
|
303
|
+
return_value=httpx.Response(201, json={**CLAIMED, "user": {"id": "u1", "email": evil}})
|
|
304
|
+
)
|
|
305
|
+
_, _, user = auth.claim_browser_login(BASE, "POLL")
|
|
306
|
+
assert user["email"] == "me]0;pwned@test[2J"
|
|
307
|
+
assert auth.display_text("\x1b ") is None
|
|
308
|
+
assert auth.display_text(7) is None
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
# --- opening a browser ------------------------------------------------------
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
@pytest.mark.parametrize(
|
|
315
|
+
"env,platform,expected",
|
|
316
|
+
[
|
|
317
|
+
({"DISPLAY": ":0"}, "linux", True),
|
|
318
|
+
({"WAYLAND_DISPLAY": "wayland-0"}, "linux", True),
|
|
319
|
+
({}, "linux", False),
|
|
320
|
+
({"DISPLAY": ":0", "SSH_TTY": "/dev/pts/1"}, "linux", False),
|
|
321
|
+
({"SSH_CONNECTION": "1.2.3.4 1 5.6.7.8 22"}, "darwin", False),
|
|
322
|
+
({"SSH_CLIENT": "1.2.3.4 1 22"}, "win32", False),
|
|
323
|
+
({}, "darwin", True),
|
|
324
|
+
({}, "win32", True),
|
|
325
|
+
],
|
|
326
|
+
)
|
|
327
|
+
def test_a_browser_is_only_opened_where_a_person_can_see_it(env, platform, expected):
|
|
328
|
+
assert auth.can_open_browser(env, platform) is expected
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def test_opening_uses_the_platform_handler_detached_and_never_raises(monkeypatch):
|
|
332
|
+
calls = []
|
|
333
|
+
|
|
334
|
+
def popen(argv, **kw):
|
|
335
|
+
calls.append((argv, kw))
|
|
336
|
+
|
|
337
|
+
monkeypatch.setattr(auth.subprocess, "Popen", popen)
|
|
338
|
+
auth.open_url(LINK, "linux")
|
|
339
|
+
auth.open_url(LINK, "darwin")
|
|
340
|
+
assert [c[0] for c in calls] == [["xdg-open", LINK], ["open", LINK]]
|
|
341
|
+
assert calls[0][1]["start_new_session"] is True
|
|
342
|
+
assert calls[0][1]["stdin"] is auth.subprocess.DEVNULL
|
|
343
|
+
|
|
344
|
+
def missing(*_a, **_k):
|
|
345
|
+
raise FileNotFoundError("xdg-open")
|
|
346
|
+
|
|
347
|
+
monkeypatch.setattr(auth.subprocess, "Popen", missing)
|
|
348
|
+
auth.open_url(LINK, "linux")
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
# --- the box, at the moment it claims ----------------------------------------
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
class _Box:
|
|
355
|
+
"""A login box with a queue of keys already pressed. `fp-login.sh` drives the real one."""
|
|
356
|
+
|
|
357
|
+
def __init__(self, *keys):
|
|
358
|
+
self.keys = list(keys)
|
|
359
|
+
self.ended = []
|
|
360
|
+
self.link = None
|
|
361
|
+
self.shown = []
|
|
362
|
+
self.notes = []
|
|
363
|
+
|
|
364
|
+
def working(self, _text):
|
|
365
|
+
pass
|
|
366
|
+
|
|
367
|
+
def show_link(self, intro, url):
|
|
368
|
+
self.shown.append((intro, url))
|
|
369
|
+
|
|
370
|
+
def note(self, label, value=None):
|
|
371
|
+
self.notes.append(label)
|
|
372
|
+
|
|
373
|
+
def waiting(self, _line, _keys):
|
|
374
|
+
pass
|
|
375
|
+
|
|
376
|
+
def link_ended(self, message):
|
|
377
|
+
self.ended.append((message, list(self.keys)))
|
|
378
|
+
raise selectmod.SwitchSignIn() # as Tab there does: it gets a test out of the loop
|
|
379
|
+
|
|
380
|
+
def wait_key(self, _seconds):
|
|
381
|
+
key = self.keys.pop(0) if self.keys else None
|
|
382
|
+
if key == "ESC":
|
|
383
|
+
raise selectmod.LoginCancelled()
|
|
384
|
+
return key
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
@pytest.fixture
|
|
388
|
+
def approved_link(monkeypatch):
|
|
389
|
+
"""A link whose last poll came back approved; returns the list of claims made."""
|
|
390
|
+
claims = []
|
|
391
|
+
monkeypatch.setattr(auth, "can_open_browser", lambda *_a: False)
|
|
392
|
+
monkeypatch.setattr(auth, "start_browser_login", lambda *_a, **_k: auth.BrowserLogin(LINK, "POLL", 60.0, 1.0))
|
|
393
|
+
monkeypatch.setattr(auth, "await_browser_approval", lambda *_a, **_k: "approved")
|
|
394
|
+
|
|
395
|
+
def claim(*_a, **_k):
|
|
396
|
+
claims.append(1)
|
|
397
|
+
return ("tok", 3600, CLAIMED["user"])
|
|
398
|
+
|
|
399
|
+
monkeypatch.setattr(auth, "claim_browser_login", claim)
|
|
400
|
+
return claims
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def _state():
|
|
404
|
+
return AppState(json=False, base_url=BASE, token=None, timeout=1.0, config=config.CliConfig())
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
@pytest.mark.parametrize("before", [(), ("x",), ("UP",), ("", "")], ids=["alone", "letter", "arrow", "non-ascii"])
|
|
408
|
+
def test_esc_pressed_during_the_last_poll_means_no_session(approved_link, before):
|
|
409
|
+
# A non-ASCII character reads as "", once per byte: not the end of the queue.
|
|
410
|
+
with pytest.raises(selectmod.LoginCancelled):
|
|
411
|
+
auth_cmds._browser_login_in_box(_state(), BASE, _Box(*before, "ESC"))
|
|
412
|
+
assert approved_link == []
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
def test_any_other_key_pressed_during_the_last_poll_changes_nothing(approved_link):
|
|
416
|
+
assert auth_cmds._browser_login_in_box(_state(), BASE, _Box("x", "ENTER"))[0] == "tok"
|
|
417
|
+
assert approved_link == [1]
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
@pytest.mark.parametrize("final", ["denied", "expired"])
|
|
421
|
+
def test_enter_pressed_during_the_last_poll_cannot_answer_a_screen_nobody_saw(approved_link, monkeypatch, final):
|
|
422
|
+
# It would take the next link straight away, with the denial on screen for no time at all.
|
|
423
|
+
monkeypatch.setattr(auth, "await_browser_approval", lambda *_a, **_k: final)
|
|
424
|
+
box = _Box("ENTER", "")
|
|
425
|
+
with pytest.raises(selectmod.SwitchSignIn):
|
|
426
|
+
auth_cmds._browser_login_in_box(_state(), BASE, box)
|
|
427
|
+
assert [keys for _message, keys in box.ended] == [[]]
|
|
428
|
+
assert box.link is None, "the next time gets a new link, not this dead one"
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
def test_esc_pressed_during_the_last_poll_of_a_denied_link_still_cancels(approved_link, monkeypatch):
|
|
432
|
+
monkeypatch.setattr(auth, "await_browser_approval", lambda *_a, **_k: "denied")
|
|
433
|
+
box = _Box("ESC")
|
|
434
|
+
with pytest.raises(selectmod.LoginCancelled):
|
|
435
|
+
auth_cmds._browser_login_in_box(_state(), BASE, box)
|
|
436
|
+
assert box.ended == []
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
def test_tab_pressed_during_the_last_poll_means_no_session(approved_link):
|
|
440
|
+
box = _Box("x", "\t")
|
|
441
|
+
with pytest.raises(selectmod.SwitchSignIn):
|
|
442
|
+
auth_cmds._browser_login_in_box(_state(), BASE, box)
|
|
443
|
+
assert approved_link == []
|
|
444
|
+
assert box.link is not None, "the approval is still there to come back to"
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
def test_tab_pressed_during_the_last_poll_of_a_denied_link_answers_nothing(approved_link, monkeypatch):
|
|
448
|
+
monkeypatch.setattr(auth, "await_browser_approval", lambda *_a, **_k: "denied")
|
|
449
|
+
box = _Box("\t")
|
|
450
|
+
with pytest.raises(selectmod.SwitchSignIn): # raised by the denied screen, once shown
|
|
451
|
+
auth_cmds._browser_login_in_box(_state(), BASE, box)
|
|
452
|
+
assert [message for message, _keys in box.ended] == ["not authorized"]
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
def test_tab_away_and_back_finds_the_same_link(approved_link, monkeypatch):
|
|
456
|
+
# Asking again would spend the rate limit, leave rows behind, and open another browser tab.
|
|
457
|
+
starts, opened = [], []
|
|
458
|
+
|
|
459
|
+
def start(*_a, **_k):
|
|
460
|
+
starts.append(1)
|
|
461
|
+
return auth.BrowserLogin(LINK, "POLL", 60.0, 1.0)
|
|
462
|
+
|
|
463
|
+
def waited(_base, _login, *, tick, **_k):
|
|
464
|
+
tick(60.0, False)
|
|
465
|
+
return "approved"
|
|
466
|
+
|
|
467
|
+
monkeypatch.setattr(auth, "start_browser_login", start)
|
|
468
|
+
monkeypatch.setattr(auth, "can_open_browser", lambda *_a: True)
|
|
469
|
+
monkeypatch.setattr(auth, "open_url", opened.append)
|
|
470
|
+
monkeypatch.setattr(auth, "await_browser_approval", waited)
|
|
471
|
+
|
|
472
|
+
box = _Box("\t")
|
|
473
|
+
with pytest.raises(selectmod.SwitchSignIn):
|
|
474
|
+
auth_cmds._browser_login_in_box(_state(), BASE, box)
|
|
475
|
+
assert auth_cmds._browser_login_in_box(_state(), BASE, box)[0] == "tok"
|
|
476
|
+
|
|
477
|
+
assert starts == [1]
|
|
478
|
+
assert opened == [LINK]
|
|
479
|
+
assert box.shown == [(auth_cmds._LINK_OPENING, LINK), (auth_cmds._LINK_ANYWHERE, LINK)]
|
|
480
|
+
assert approved_link == [1]
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
def test_the_link_goes_on_screen_before_any_browser_opens(approved_link, monkeypatch):
|
|
484
|
+
box = _Box()
|
|
485
|
+
monkeypatch.setattr(auth, "can_open_browser", lambda *_a: True)
|
|
486
|
+
monkeypatch.setattr(auth, "open_url", lambda url: box.shown.append(("opened", url)))
|
|
487
|
+
auth_cmds._browser_login_in_box(_state(), BASE, box)
|
|
488
|
+
assert [what for what, _url in box.shown] == [auth_cmds._LINK_OPENING, "opened"]
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
class _EmailBox(_Box):
|
|
492
|
+
"""``text_step`` answers from a script: text to accept, or a Tab with what had been typed."""
|
|
493
|
+
|
|
494
|
+
def __init__(self, *steps):
|
|
495
|
+
super().__init__()
|
|
496
|
+
self.steps = list(steps)
|
|
497
|
+
self.asked = []
|
|
498
|
+
|
|
499
|
+
def text_step(self, label, *, helper=None, value="", tab=False, **_k):
|
|
500
|
+
self.asked.append((label, value, tab, helper))
|
|
501
|
+
step = self.steps.pop(0)
|
|
502
|
+
if isinstance(step, Exception):
|
|
503
|
+
raise step
|
|
504
|
+
return step
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
@pytest.fixture
|
|
508
|
+
def emailed_code(monkeypatch):
|
|
509
|
+
monkeypatch.setattr(auth, "request_otp", lambda *_a, **_k: None)
|
|
510
|
+
monkeypatch.setattr(auth, "verify_otp", lambda *_a, **_k: ("tok-otp", 3600, CLAIMED["user"]))
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
def test_tab_at_the_link_goes_to_the_email_and_back_keeping_what_was_typed(emailed_code, monkeypatch):
|
|
514
|
+
def left(*_a, **_k):
|
|
515
|
+
raise selectmod.SwitchSignIn()
|
|
516
|
+
|
|
517
|
+
monkeypatch.setattr(auth_cmds, "_browser_login_in_box", left)
|
|
518
|
+
box = _EmailBox(selectmod.SwitchSignIn("me@te"), "me@test", "123456")
|
|
519
|
+
|
|
520
|
+
method, creds = auth_cmds._sign_in_in_box(_state(), BASE, box, None)
|
|
521
|
+
|
|
522
|
+
assert (method, creds[0]) == ("email", "tok-otp")
|
|
523
|
+
assert [(label, value, tab) for label, value, tab, _helper in box.asked] == [
|
|
524
|
+
("email", "", True), ("email", "me@te", True), ("code", "", False),
|
|
525
|
+
]
|
|
526
|
+
assert box.asked[0][3] == "enter send a code · tab SSO · esc cancel"
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
def test_login_starts_on_the_link_and_never_asks_for_an_email(approved_link):
|
|
530
|
+
box = _EmailBox()
|
|
531
|
+
method, creds = auth_cmds._sign_in_in_box(_state(), BASE, box, None)
|
|
532
|
+
assert (method, creds[0]) == ("browser", "tok")
|
|
533
|
+
assert approved_link == [1]
|
|
534
|
+
assert box.asked == []
|
|
535
|
+
assert box.shown == [(auth_cmds._LINK_ANYWHERE, LINK)]
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
def _uses_the_code(box):
|
|
539
|
+
label, value, tab, helper = box.asked[0]
|
|
540
|
+
assert (label, value, tab) == ("email", "", False)
|
|
541
|
+
assert "tab" not in helper
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
def test_a_cloud_without_browser_login_uses_the_code_and_offers_no_tab(emailed_code, monkeypatch):
|
|
545
|
+
monkeypatch.setattr(auth, "start_browser_login", lambda *_a, **_k: None)
|
|
546
|
+
box = _EmailBox("me@test", "123456")
|
|
547
|
+
|
|
548
|
+
method, _creds = auth_cmds._sign_in_in_box(_state(), BASE, box, None)
|
|
549
|
+
|
|
550
|
+
assert method == "email"
|
|
551
|
+
assert box.notes[0] == auth_cmds._NO_BROWSER_LOGIN
|
|
552
|
+
_uses_the_code(box)
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
@pytest.mark.parametrize(
|
|
556
|
+
"failure",
|
|
557
|
+
[ApiError("Too many login attempts", status=429), NetworkError("answered HTTP 502")],
|
|
558
|
+
ids=["rate-limited", "server-error"],
|
|
559
|
+
)
|
|
560
|
+
def test_failing_to_get_a_link_still_leaves_the_emailed_code(emailed_code, monkeypatch, failure):
|
|
561
|
+
# The link is only the default, so it must not be the only way in.
|
|
562
|
+
def refused(*_a, **_k):
|
|
563
|
+
raise failure
|
|
564
|
+
|
|
565
|
+
monkeypatch.setattr(auth, "start_browser_login", refused)
|
|
566
|
+
box = _EmailBox("me@test", "123456")
|
|
567
|
+
|
|
568
|
+
method, creds = auth_cmds._sign_in_in_box(_state(), BASE, box, None)
|
|
569
|
+
|
|
570
|
+
assert (method, creds[0]) == ("email", "tok-otp")
|
|
571
|
+
assert box.notes[0] == auth_cmds._NO_LINK_NOW
|
|
572
|
+
_uses_the_code(box)
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
def test_a_claim_that_fails_is_not_mistaken_for_having_no_link(approved_link, monkeypatch):
|
|
576
|
+
# Someone approved this. Dropping to a code would hide why it didn't work.
|
|
577
|
+
def refused(*_a, **_k):
|
|
578
|
+
raise ApiError("approval_revoked", status=403)
|
|
579
|
+
|
|
580
|
+
monkeypatch.setattr(auth, "claim_browser_login", refused)
|
|
581
|
+
with pytest.raises(ApiError, match="approval_revoked"):
|
|
582
|
+
auth_cmds._sign_in_in_box(_state(), BASE, _EmailBox(), None)
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
def test_the_email_flag_goes_straight_to_the_code(emailed_code, monkeypatch):
|
|
586
|
+
monkeypatch.setattr(auth, "start_browser_login", lambda *_a, **_k: pytest.fail("asked for a link"))
|
|
587
|
+
box = _EmailBox("123456")
|
|
588
|
+
assert auth_cmds._sign_in_in_box(_state(), BASE, box, "me@test")[0] == "email"
|
|
589
|
+
assert [label for label, *_rest in box.asked] == ["code"]
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
LONG_LINK = "https://app.befailproof.ai/cli/authorize?r=" + "a" * 64 # 107 characters
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
@pytest.mark.parametrize(
|
|
596
|
+
"width,indent,rows",
|
|
597
|
+
[(200, " ", 1), (110, " ", 1), (109, " ", 1), (108, "", 1), (107, "", 1), (106, "", 2), (80, "", 2), (54, "", 2), (53, "", 3)],
|
|
598
|
+
)
|
|
599
|
+
def test_a_link_stays_whole_and_its_rows_are_counted(monkeypatch, width, indent, rows):
|
|
600
|
+
# Rich mustn't break it, and a wrong count leaves stray rows on screen or eats the ones above.
|
|
601
|
+
console = Console(file=io.StringIO(), force_terminal=True, width=width, color_system=None)
|
|
602
|
+
monkeypatch.setattr(output, "_stderr", console)
|
|
603
|
+
|
|
604
|
+
taken = output.print_login_link([("code", None)], "open this link:", LONG_LINK)
|
|
605
|
+
|
|
606
|
+
printed = console.file.getvalue()
|
|
607
|
+
# Right under the box, never inside its border. It lines up with the box when it fits, and
|
|
608
|
+
# starts at the margin when it doesn't, so its rows line up with each other.
|
|
609
|
+
under_the_box = printed.split("╯")[-1]
|
|
610
|
+
assert under_the_box.strip("\n ") == LONG_LINK
|
|
611
|
+
assert f"\n{indent}{LONG_LINK}\n" in under_the_box
|
|
612
|
+
box = ["╭─ ◆ fp ─╮", "welcome", "✓ code", "❯ open this link:", "╰────╯", "blank above the link"]
|
|
613
|
+
assert taken == len(box) + rows + len(["blank below the link"])
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
def test_the_box_leaves_the_link_alone_until_it_takes_it_down_row_by_row(monkeypatch):
|
|
617
|
+
monkeypatch.setenv("TERM", "xterm") # Live draws nothing on a dumb terminal
|
|
618
|
+
console = Console(file=io.StringIO(), force_terminal=True, width=80, color_system=None)
|
|
619
|
+
monkeypatch.setattr(output, "_stderr", console)
|
|
620
|
+
monkeypatch.setattr("sys.stdin", SimpleNamespace(fileno=lambda: 0))
|
|
621
|
+
box = selectmod.LoginBox()
|
|
622
|
+
box._live = Live(console=console, auto_refresh=False)
|
|
623
|
+
|
|
624
|
+
def written_by(step):
|
|
625
|
+
console.file.seek(0)
|
|
626
|
+
console.file.truncate()
|
|
627
|
+
step()
|
|
628
|
+
return console.file.getvalue()
|
|
629
|
+
|
|
630
|
+
with box._live:
|
|
631
|
+
assert LONG_LINK in written_by(lambda: box.show_link("open this link:", LONG_LINK))
|
|
632
|
+
for _tick in range(2): # redrawing it would clear a person's selection
|
|
633
|
+
tick = written_by(lambda: box.waiting("waiting", "keys"))
|
|
634
|
+
assert "waiting" in tick and LONG_LINK not in tick
|
|
635
|
+
taken_down = written_by(box._draw)
|
|
636
|
+
# The box (border, welcome, the ask, border), a blank, two rows of link, a blank, and the
|
|
637
|
+
# waiting line's own row.
|
|
638
|
+
assert taken_down.count("\x1b[1A\x1b[2K") == 4 + 1 + 2 + 1 + 1
|
|
639
|
+
# Nothing more to take down: only the frame's own rows (border, welcome, border).
|
|
640
|
+
assert written_by(box._draw).count("\x1b[1A\x1b[2K") == 2
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
def test_cancelling_leaves_no_prompt_behind(monkeypatch):
|
|
644
|
+
monkeypatch.setenv("TERM", "xterm")
|
|
645
|
+
console = Console(file=io.StringIO(), force_terminal=True, width=80, color_system=None)
|
|
646
|
+
monkeypatch.setattr(output, "_stderr", console)
|
|
647
|
+
monkeypatch.setattr("sys.stdin", SimpleNamespace(fileno=lambda: 0))
|
|
648
|
+
box = selectmod.LoginBox()
|
|
649
|
+
box._live = Live(console=console, auto_refresh=False)
|
|
650
|
+
box.active = "email"
|
|
651
|
+
with box._live:
|
|
652
|
+
box._draw()
|
|
653
|
+
console.file.seek(0)
|
|
654
|
+
console.file.truncate()
|
|
655
|
+
box.cancel(False)
|
|
656
|
+
closing = console.file.getvalue()
|
|
657
|
+
assert "cancelled" in closing and "❯ email" not in closing
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
@pytest.mark.parametrize("step", ["start_browser_login", "claim_browser_login"])
|
|
661
|
+
def test_ctrl_c_during_any_request_of_a_browser_login_cancels_calmly(approved_link, monkeypatch, step):
|
|
662
|
+
def interrupted(*_a, **_k):
|
|
663
|
+
raise KeyboardInterrupt()
|
|
664
|
+
|
|
665
|
+
monkeypatch.setattr(auth, step, interrupted)
|
|
666
|
+
with pytest.raises(selectmod.LoginCancelled):
|
|
667
|
+
auth_cmds._browser_login_in_box(_state(), BASE, _Box())
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
# --- the command, on a terminal with no raw mode ----------------------------
|
|
671
|
+
#
|
|
672
|
+
# The box needs termios and a real pty, so this is the path CliRunner can reach:
|
|
673
|
+
# stdin stubbed as a terminal, the box stubbed as unavailable. It is what Windows gets,
|
|
674
|
+
# and every decision it makes about a server's answer is the box's too.
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
@pytest.fixture
|
|
678
|
+
def plain_terminal(monkeypatch):
|
|
679
|
+
monkeypatch.setattr("fp_cli.select.stdin_is_tty", lambda: True)
|
|
680
|
+
monkeypatch.setattr("fp_cli.select.stderr_is_tty", lambda: True)
|
|
681
|
+
monkeypatch.setattr("fp_cli.select.login_box_supported", lambda: False)
|
|
682
|
+
# Never a real browser from a test run, wherever it runs.
|
|
683
|
+
monkeypatch.setattr(auth, "open_url", lambda *_a, **_k: pytest.fail("opened a browser"))
|
|
684
|
+
monkeypatch.setenv("SSH_TTY", "/dev/pts/1")
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
def _approved_on_first_poll():
|
|
688
|
+
respx.post(f"{BASE}/api/auth/cli/poll").mock(return_value=httpx.Response(200, json={"status": "approved"}))
|
|
689
|
+
respx.get(f"{BASE}/api/auth/session").mock(return_value=httpx.Response(200, json=SESSION))
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
def _fast_links(monkeypatch):
|
|
693
|
+
real = auth.start_browser_login
|
|
694
|
+
|
|
695
|
+
def start(*a, **k):
|
|
696
|
+
login = real(*a, **k)
|
|
697
|
+
return login and auth.BrowserLogin(login.verification_url, login.poll_secret, 60.0, 0.0)
|
|
698
|
+
|
|
699
|
+
monkeypatch.setattr(auth, "start_browser_login", start)
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
@respx.mock
|
|
703
|
+
def test_choosing_browser_signs_in_without_any_email(home, runner, plain_terminal, monkeypatch):
|
|
704
|
+
_fast_links(monkeypatch)
|
|
705
|
+
respx.post(f"{BASE}/api/auth/cli/start").mock(return_value=_start())
|
|
706
|
+
respx.post(f"{BASE}/api/auth/cli/claim").mock(return_value=httpx.Response(201, json=CLAIMED))
|
|
707
|
+
_approved_on_first_poll()
|
|
708
|
+
otp = respx.post(f"{BASE}/api/auth/otp/request")
|
|
709
|
+
|
|
710
|
+
result = runner.invoke(app, ["--base-url", BASE, "login"], input="\n")
|
|
711
|
+
|
|
712
|
+
assert result.exit_code == 0, result.output
|
|
713
|
+
assert LINK in result.output
|
|
714
|
+
assert not otp.called
|
|
715
|
+
cfg = config.load_config()
|
|
716
|
+
assert (cfg.session_token, cfg.email, cfg.org) == ("tok-browser", "me@test", "acme")
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
@respx.mock
|
|
720
|
+
def test_a_cloud_without_browser_login_falls_back_to_the_emailed_code(home, runner, plain_terminal):
|
|
721
|
+
respx.post(f"{BASE}/api/auth/cli/start").mock(return_value=httpx.Response(404))
|
|
722
|
+
respx.post(f"{BASE}/api/auth/otp/request").mock(return_value=httpx.Response(200, json={"ok": True}))
|
|
723
|
+
respx.post(f"{BASE}/api/auth/otp/verify").mock(
|
|
724
|
+
return_value=httpx.Response(
|
|
725
|
+
200,
|
|
726
|
+
json={"user": {"id": "u1", "email": "me@test"}, "expires_in_secs": 3600},
|
|
727
|
+
headers={"set-cookie": "ae_session=tok-otp; Path=/"},
|
|
728
|
+
)
|
|
729
|
+
)
|
|
730
|
+
respx.get(f"{BASE}/api/auth/session").mock(return_value=httpx.Response(200, json=SESSION))
|
|
731
|
+
|
|
732
|
+
result = runner.invoke(app, ["--base-url", BASE, "login"], input="\nme@test\n123456\n")
|
|
733
|
+
|
|
734
|
+
assert result.exit_code == 0, result.output
|
|
735
|
+
assert "no browser login" in result.output
|
|
736
|
+
assert config.load_config().session_token == "tok-otp"
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
@respx.mock
|
|
740
|
+
@pytest.mark.parametrize("failed", [429, 500], ids=["rate-limited", "server-error"])
|
|
741
|
+
def test_failing_to_get_a_link_on_a_plain_terminal_still_leaves_the_emailed_code(home, runner, plain_terminal, failed):
|
|
742
|
+
respx.post(f"{BASE}/api/auth/cli/start").mock(return_value=httpx.Response(failed, json={"error": "nope"}))
|
|
743
|
+
otp = respx.post(f"{BASE}/api/auth/otp/request").mock(return_value=httpx.Response(200, json={"ok": True}))
|
|
744
|
+
respx.post(f"{BASE}/api/auth/otp/verify").mock(
|
|
745
|
+
return_value=httpx.Response(
|
|
746
|
+
200,
|
|
747
|
+
json={"user": {"id": "u1", "email": "me@test"}, "expires_in_secs": 3600},
|
|
748
|
+
headers={"set-cookie": "ae_session=tok-otp; Path=/"},
|
|
749
|
+
)
|
|
750
|
+
)
|
|
751
|
+
respx.get(f"{BASE}/api/auth/session").mock(return_value=httpx.Response(200, json=SESSION))
|
|
752
|
+
|
|
753
|
+
result = runner.invoke(app, ["--base-url", BASE, "login"], input="\nme@test\n123456\n")
|
|
754
|
+
|
|
755
|
+
assert result.exit_code == 0, result.output
|
|
756
|
+
assert auth_cmds._NO_LINK_NOW in result.output
|
|
757
|
+
assert otp.called
|
|
758
|
+
assert config.load_config().session_token == "tok-otp"
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
@respx.mock
|
|
762
|
+
def test_a_cloud_that_dropped_the_kind_is_never_claimed_from(home, runner, plain_terminal):
|
|
763
|
+
respx.post(f"{BASE}/api/auth/cli/start").mock(
|
|
764
|
+
return_value=httpx.Response(201, json={k: v for k, v in STARTED.items() if k != "kind"})
|
|
765
|
+
)
|
|
766
|
+
claim = respx.post(f"{BASE}/api/auth/cli/claim")
|
|
767
|
+
poll = respx.post(f"{BASE}/api/auth/cli/poll")
|
|
768
|
+
respx.post(f"{BASE}/api/auth/otp/request").mock(return_value=httpx.Response(200, json={"ok": True}))
|
|
769
|
+
respx.post(f"{BASE}/api/auth/otp/verify").mock(return_value=httpx.Response(401))
|
|
770
|
+
|
|
771
|
+
runner.invoke(app, ["--base-url", BASE, "login"], input="\nme@test\n000000\n")
|
|
772
|
+
|
|
773
|
+
assert not poll.called and not claim.called
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
@respx.mock
|
|
777
|
+
@pytest.mark.parametrize("final", ["denied", "expired", "claimed"])
|
|
778
|
+
def test_a_link_that_ends_leaves_nothing_saved(home, runner, plain_terminal, monkeypatch, final):
|
|
779
|
+
_fast_links(monkeypatch)
|
|
780
|
+
respx.post(f"{BASE}/api/auth/cli/start").mock(return_value=_start())
|
|
781
|
+
respx.post(f"{BASE}/api/auth/cli/poll").mock(return_value=httpx.Response(200, json={"status": final}))
|
|
782
|
+
claim = respx.post(f"{BASE}/api/auth/cli/claim")
|
|
783
|
+
|
|
784
|
+
result = runner.invoke(app, ["--base-url", BASE, "login"], input="\n")
|
|
785
|
+
|
|
786
|
+
assert result.exit_code == 4, result.output
|
|
787
|
+
assert not claim.called
|
|
788
|
+
assert config.load_config().session_token is None
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
@respx.mock
|
|
792
|
+
def test_an_email_at_the_prompt_is_the_email_and_starts_no_link(home, runner, plain_terminal):
|
|
793
|
+
start = respx.post(f"{BASE}/api/auth/cli/start")
|
|
794
|
+
otp = respx.post(f"{BASE}/api/auth/otp/request").mock(return_value=httpx.Response(200, json={"ok": True}))
|
|
795
|
+
respx.post(f"{BASE}/api/auth/otp/verify").mock(return_value=httpx.Response(401))
|
|
796
|
+
|
|
797
|
+
runner.invoke(app, ["--base-url", BASE, "login"], input="me@test\n000000\n")
|
|
798
|
+
|
|
799
|
+
assert not start.called
|
|
800
|
+
assert json.loads(otp.calls[0].request.content)["email"] == "me@test"
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
@respx.mock
|
|
804
|
+
def test_ctrl_c_while_waiting_cancels_calmly(home, runner, plain_terminal, monkeypatch):
|
|
805
|
+
respx.post(f"{BASE}/api/auth/cli/start").mock(return_value=_start())
|
|
806
|
+
claim = respx.post(f"{BASE}/api/auth/cli/claim")
|
|
807
|
+
|
|
808
|
+
def interrupted(*_a, **_k):
|
|
809
|
+
raise KeyboardInterrupt()
|
|
810
|
+
|
|
811
|
+
monkeypatch.setattr(auth, "await_browser_approval", interrupted)
|
|
812
|
+
|
|
813
|
+
result = runner.invoke(app, ["--base-url", BASE, "login"], input="\n")
|
|
814
|
+
|
|
815
|
+
assert result.exit_code == 0, result.output
|
|
816
|
+
assert "cancelled" in result.output
|
|
817
|
+
assert not claim.called
|
|
818
|
+
assert config.load_config().session_token is None
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
@respx.mock
|
|
822
|
+
def test_the_plain_flow_says_when_it_is_reconnecting_once(home, runner, plain_terminal, monkeypatch):
|
|
823
|
+
_fast_links(monkeypatch)
|
|
824
|
+
respx.post(f"{BASE}/api/auth/cli/start").mock(return_value=_start())
|
|
825
|
+
respx.post(f"{BASE}/api/auth/cli/poll").mock(
|
|
826
|
+
side_effect=[
|
|
827
|
+
httpx.ConnectError("x"),
|
|
828
|
+
httpx.ConnectError("x"),
|
|
829
|
+
httpx.Response(200, json={"status": "pending"}),
|
|
830
|
+
httpx.Response(200, json={"status": "approved"}),
|
|
831
|
+
]
|
|
832
|
+
)
|
|
833
|
+
respx.post(f"{BASE}/api/auth/cli/claim").mock(return_value=httpx.Response(201, json=CLAIMED))
|
|
834
|
+
respx.get(f"{BASE}/api/auth/session").mock(return_value=httpx.Response(200, json=SESSION))
|
|
835
|
+
|
|
836
|
+
result = runner.invoke(app, ["--base-url", BASE, "login"], input="\n")
|
|
837
|
+
|
|
838
|
+
assert result.exit_code == 0, result.output
|
|
839
|
+
assert result.output.count("reconnecting") == 1
|
|
840
|
+
assert "back online" in result.output
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
@respx.mock
|
|
844
|
+
def test_the_plain_flow_says_it_is_back_when_the_next_answer_is_the_approval(home, runner, plain_terminal, monkeypatch):
|
|
845
|
+
_fast_links(monkeypatch)
|
|
846
|
+
respx.post(f"{BASE}/api/auth/cli/start").mock(return_value=_start())
|
|
847
|
+
respx.post(f"{BASE}/api/auth/cli/poll").mock(
|
|
848
|
+
side_effect=[httpx.ConnectError("x"), httpx.Response(200, json={"status": "approved"})]
|
|
849
|
+
)
|
|
850
|
+
respx.post(f"{BASE}/api/auth/cli/claim").mock(return_value=httpx.Response(201, json=CLAIMED))
|
|
851
|
+
respx.get(f"{BASE}/api/auth/session").mock(return_value=httpx.Response(200, json=SESSION))
|
|
852
|
+
|
|
853
|
+
result = runner.invoke(app, ["--base-url", BASE, "login"], input="\n")
|
|
854
|
+
|
|
855
|
+
assert result.exit_code == 0, result.output
|
|
856
|
+
assert result.output.index("reconnecting") < result.output.index("back online")
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
@respx.mock
|
|
860
|
+
def test_a_redirected_stderr_keeps_the_old_prompts(home, runner, plain_terminal, monkeypatch):
|
|
861
|
+
# The link and the waiting would go to that file, and the person would watch nothing.
|
|
862
|
+
monkeypatch.setattr("fp_cli.select.stderr_is_tty", lambda: False)
|
|
863
|
+
start = respx.post(f"{BASE}/api/auth/cli/start")
|
|
864
|
+
respx.post(f"{BASE}/api/auth/otp/request").mock(return_value=httpx.Response(200, json={"ok": True}))
|
|
865
|
+
respx.post(f"{BASE}/api/auth/otp/verify").mock(
|
|
866
|
+
return_value=httpx.Response(
|
|
867
|
+
200,
|
|
868
|
+
json={"user": {"id": "u1", "email": "me@test"}, "expires_in_secs": 3600},
|
|
869
|
+
headers={"set-cookie": "ae_session=tok-otp; Path=/"},
|
|
870
|
+
)
|
|
871
|
+
)
|
|
872
|
+
respx.get(f"{BASE}/api/auth/session").mock(return_value=httpx.Response(200, json=SESSION))
|
|
873
|
+
|
|
874
|
+
result = runner.invoke(app, ["--base-url", BASE, "login"], input="me@test\n123456\n")
|
|
875
|
+
|
|
876
|
+
assert result.exit_code == 0, result.output
|
|
877
|
+
assert not start.called
|
|
878
|
+
assert "browser link" not in result.output
|
|
879
|
+
assert config.load_config().session_token == "tok-otp"
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
@respx.mock
|
|
883
|
+
def test_choosing_email_never_touches_the_browser_routes(home, runner, plain_terminal):
|
|
884
|
+
start = respx.post(f"{BASE}/api/auth/cli/start")
|
|
885
|
+
respx.post(f"{BASE}/api/auth/otp/request").mock(return_value=httpx.Response(200, json={"ok": True}))
|
|
886
|
+
respx.post(f"{BASE}/api/auth/otp/verify").mock(
|
|
887
|
+
return_value=httpx.Response(
|
|
888
|
+
200,
|
|
889
|
+
json={"user": {"id": "u1", "email": "me@test"}, "expires_in_secs": 3600},
|
|
890
|
+
headers={"set-cookie": "ae_session=tok-otp; Path=/"},
|
|
891
|
+
)
|
|
892
|
+
)
|
|
893
|
+
respx.get(f"{BASE}/api/auth/session").mock(return_value=httpx.Response(200, json=SESSION))
|
|
894
|
+
|
|
895
|
+
result = runner.invoke(app, ["--base-url", BASE, "login"], input="me@test\n123456\n")
|
|
896
|
+
|
|
897
|
+
assert result.exit_code == 0, result.output
|
|
898
|
+
assert not start.called
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
@respx.mock
|
|
902
|
+
@pytest.mark.parametrize(
|
|
903
|
+
"args,tty,stdin",
|
|
904
|
+
[
|
|
905
|
+
(["--base-url", BASE, "login", "--email", "me@test"], True, "123456\n"),
|
|
906
|
+
(["--base-url", BASE, "--json", "login"], True, "me@test\n123456\n"),
|
|
907
|
+
(["--base-url", BASE, "login"], False, "me@test\n123456\n"),
|
|
908
|
+
],
|
|
909
|
+
)
|
|
910
|
+
def test_email_flag_json_and_no_terminal_are_never_offered_a_link(home, runner, monkeypatch, args, tty, stdin):
|
|
911
|
+
monkeypatch.setattr("fp_cli.select.stdin_is_tty", lambda: tty)
|
|
912
|
+
monkeypatch.setattr("fp_cli.select.login_box_supported", lambda: False)
|
|
913
|
+
start = respx.post(f"{BASE}/api/auth/cli/start")
|
|
914
|
+
respx.post(f"{BASE}/api/auth/otp/request").mock(return_value=httpx.Response(200, json={"ok": True}))
|
|
915
|
+
respx.post(f"{BASE}/api/auth/otp/verify").mock(
|
|
916
|
+
return_value=httpx.Response(
|
|
917
|
+
200,
|
|
918
|
+
json={"user": {"id": "u1", "email": "me@test"}, "expires_in_secs": 3600},
|
|
919
|
+
headers={"set-cookie": "ae_session=tok-otp; Path=/"},
|
|
920
|
+
)
|
|
921
|
+
)
|
|
922
|
+
respx.get(f"{BASE}/api/auth/session").mock(return_value=httpx.Response(200, json=SESSION))
|
|
923
|
+
|
|
924
|
+
result = runner.invoke(app, args, input=stdin)
|
|
925
|
+
|
|
926
|
+
assert result.exit_code == 0, result.output
|
|
927
|
+
assert not start.called
|
|
928
|
+
assert "browser link" not in result.output
|
|
929
|
+
assert config.load_config().session_token == "tok-otp"
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
@respx.mock
|
|
933
|
+
def test_a_blank_line_without_a_terminal_starts_no_link(home, runner, monkeypatch):
|
|
934
|
+
# At a terminal a blank answer means the link. Down a pipe nobody could see one.
|
|
935
|
+
monkeypatch.setattr("fp_cli.select.stdin_is_tty", lambda: False)
|
|
936
|
+
monkeypatch.setattr("fp_cli.select.login_box_supported", lambda: False)
|
|
937
|
+
start = respx.post(f"{BASE}/api/auth/cli/start")
|
|
938
|
+
respx.post(f"{BASE}/api/auth/otp/request").mock(return_value=httpx.Response(200, json={"ok": True}))
|
|
939
|
+
respx.post(f"{BASE}/api/auth/otp/verify").mock(return_value=httpx.Response(401))
|
|
940
|
+
|
|
941
|
+
runner.invoke(app, ["--base-url", BASE, "login"], input="\nme@test\n000000\n")
|
|
942
|
+
|
|
943
|
+
assert not start.called
|