+
    5mje  c                      ^ RI Ht ^ RIt^ RIHu Ht ^ RIt^ RI	t	^ RI
Ht ^ RIt^ RIHtHtHt ^ RIHt ^ RIHt R R ltR	 R
 ltR R ltR R ltR R ltR R ltR R ltR R ltR# )    )annotationsN)Path)AccountRegistryAccountRegistryKindPROTECTED_GROK_SLUG)GrokAuthOperation)GrokHealthClientc                    V ^8  d   QhRRRR/# )   pathr   returnNone )formats   "b/home/user/overdeck-private-tests/workstation-ai-broad/modules/systray/tests/test_grok_accounts.py__annotate__r      s      4 D     c                    V P                   P                  R R R7       V P                  \        P                  ! RRRRRRRR	R
RR//4      R,           RR7       \
        P                  ! V R4       R# )T)parentsexist_okzhttps://auth.x.ai::testkeyzaccess-tokenrefresh_tokenzrefresh-token	auth_modeoidcemailzroy@example.comprincipal_idzprincipal-roy
zutf-8)encodingi  N)parentmkdir
write_textjsondumpsoschmod)r   s   &r   _write_fake_authr%      s|    KKdT2OO

)>#_."O,
	
 	    HHT5r   c               $    V ^8  d   QhRRRRRR/# r
   tmp_pathr   monkeypatchpytest.MonkeyPatchr   r   r   )r   s   "r   r   r   "   s#     3 34 3FX 3]a 3r   c                
   V R ,          pV R,          pVR,          p\        V4       VP                  4       p\        V\        P                  VR7      p\        V4      pR R lpVP                  RV4       VP                  \        \        VR7      p	V	P                  R,          p
V
P                  q! 4       qV8H  q'       Eg   \        P                  ! RV3RW34      RR	\        P                  ! 4       9   g   \        P                  ! V
4      '       d   \        P                  ! V
4      MR	R
\        P                  ! V4      R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          pRRV/,          p\!        \        P"                  ! V4      4      hR;p;rVP$                  q! 4       q\        8H  q'       Eg"   \        P                  ! RV3RV\        34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR
\        P                  ! V4      R\        P                  ! V4      RR\        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MR/,          pRRV/,          p\!        \        P"                  ! V4      4      hR;p;rVP&                  q! 4       q'       g   RRR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR
\        P                  ! V4      R\        P                  ! V4      /,          p\!        \        P"                  ! V4      4      hR;rVP(                  q! 4       qP(                  pV! 4       pVV8H  q'       EgB   \        P                  ! RV3RVV34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR
\        P                  ! V4      R\        P                  ! V4      RR	\        P                  ! 4       9   g   \        P                  ! V
4      '       d   \        P                  ! V
4      MR	R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\!        \        P"                  ! V4      4      hR;p;p;p;ppR# )traylegacy-grok	auth.jsonbase_dirkindlegacy_grok_homec               $    V ^8  d   QhRRRRRR/# r
   _argsobject_kwargsr   r   r   )r   s   "r   r   :test_import_from_legacy_is_copy_only.<locals>.__annotate__0   s&     C CV C C4 Cr   c                     \        R 4      h)z"must not hit network during importAssertionErrorr5   r7   s   *,r   boom2test_import_from_legacy_is_copy_only.<locals>.boom0   s    ABBr   -grok_auth_operation.GrokOAuthSession.get_userslugaliaslegacy_authpy0destpy2py4py6originalassert %(py8)spy8Nregistryr   zEassert %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.is_symlink
}()
}rC   py10zassert %(py12)spy12==zI%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.read_bytes
}()
} == %(py6)szK%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.default_slug
}()
} == %(py6)s)z|%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.resolve
}()
} == %(py10)s
{%(py10)s = %(py8)s
{%(py8)s = %(py6)s.resolve
}()
})r%   
read_bytesr   r   GROKr   setattrimport_from_legacy_homer   account_home
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprr;   _format_explanationdefault_slug
is_symlinkresolve)r(   r)   baselegacy_homerC   rI   rL   opr=   accountrE   @py_assert1@py_assert3@py_assert5@py_format7@py_format9@py_format5@py_assert7@py_assert9@py_format11@py_format13s   &&                   r   $test_import_from_legacy_is_copy_onlyrp   "   s   fD]*K+K[!%%'H %%$H
 
8	$BC GN(( ! ) G +-D??(?((((((((((((4((((4(((?(((((((((((((((((((((  9 "9&999999"&9999999899998999 999"999999&99999&999999999!!#!#########;####;###!##########2 2LL2LN2 N22222 N222222;2222;222222 222222D2222D222L222N222222222r   c                    V ^8  d   QhRRRR/# r
   r(   r   r   r   r   )r   s   "r   r   r   B   s     - - - -r   c                r   V R ,          pV R,          p\        VR,          4       \        V\        P                  VR7      p\	        V4      P                  VR,          R7       \        P                  ! \        4      ;_uu_ 4        VP                  \        4       RRR4       R#   + '       g   i     R# ; i)r,   r-   r.   r/   rC   N)r%   r   r   rT   r   rV   pytestraisesPermissionErrorremover   )r(   rb   rc   rL   s   &   r   !test_roy_grok_remove_is_protectedry   B   s    fD]*K[;./ %%$H
 h77KR]D]7^		'	'+, 
(	'	'	's   B%%B6	c                    V ^8  d   QhRRRR/# rr   r   )r   s   "r   r   r   P   s     B Bd BW[ Br   c                V   V R ,          pV R,          p\        VR,          4       \        V\        P                  VR7      p\	        V4      P                  VR,          R7       VP                  pRqT! \        V4      qf\        8H  qw'       Eg   \        P                  ! RV3RV\        34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R	R
\        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MR
R\        P                  ! V4      R\        P                  ! V4      RR
\        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MR
/,          pRRV/,          p	\        \        P                  ! V	4      4      hR;p;p;rgVP!                  4       ^ ,          p
V
P"                  V
P$                  3p\        R3qV8H  q'       gy   \        P                  ! RV3RW34      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;rVP&                  qD\        ,          qUP(                  pV! 4       pV'       Eg   RRR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R	R
\        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      MR
R\        P                  ! V4      R\        P                  ! V4      /,          p\        \        P                  ! V4      4      hR;p;p;ppR# )r,   r-   r.   r/   rt   zRoy Grok WorkrD   rL   rF   py3r   py5py7py9zassert %(py11)spy11Npy1rG   assert %(py6)srH   zoassert %(py8)s
{%(py8)s = %(py6)s
{%(py6)s = (%(py2)s
{%(py2)s = %(py0)s.accounts_dir
} / %(py3)s).is_dir
}()
}rK   rO   )zU%(py7)s
{%(py7)s = %(py2)s
{%(py2)s = %(py0)s.rename
}(%(py3)s, %(py5)s)
} == %(py9)sz%(py1)s == %(py4)s)r%   r   r   rT   r   rV   renamer   rX   rY   rZ   r[   r\   r]   r;   r^   listrA   rB   accounts_diris_dir)r(   rb   rc   rL   rf   @py_assert4@py_assert6@py_assert8@py_format10@py_format12re   @py_assert0rg   @py_assert2rk   ri   rh   rl   rj   s   &                  r   ?test_roy_grok_rename_relabels_without_moving_the_protected_slugr   P   sQ   fD]*K[;./ %%$H
 h77KR]D]7^??WW?.@WDWWWWWW@DWWWWWWW8WWWW8WWW?WWWWWW.WWWW.WWWWWW@WWWWWWDWWWWWDWWWWWWWWWmmoa GLL'--(R-@/,RR,RRRRRR(RRR(RRR,RRRRRRRRR!!A$77A??A?AAAAAAAAAAHAAAAHAAA!AAAAAA$7AAAA$7AAA?AAAAAAAAAAAr   c               $    V ^8  d   QhRRRRRR/# r'   r   )r   s   "r   r   r   b   s(     N N NCU NZ^ Nr   c           	        VP                  R RR7       V R,          pV R,          p\        VR,          4       \        V\        P                  VR7      p\        V4      pVP                  VR,          R7      pR R	 lpVP                  R
V4       \        VP                  V4      4      pV U	u. uF  qP                  NK  	  p
p	R.qV8H  q'       gy   \        P                  ! RV3RW34      R\        P                  ! V
4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p
;r. q^ ,          qP                   pRpVVJpTp
V'       d   RpV^ ,          pVP                   pVV9   pTp
V
'       EgS   \        P                  ! R V3R!VV34      R\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          pVP#                  V4       V'       d   \        P                  ! R"X3R#XX34      R\        P                  ! V4      R\        P                  ! X4      R\        P                  ! V4      /,          pRRV/,          pVP#                  V4       \        P$                  ! V^ 4      / ,          pRRV/,          p\        \        P                  ! V4      4      hR;p
;p;p;p;p;p;p;p;ppR# u up	i )$SYSTRAY_ALLOW_ROY_GROK_MUTATIONF)raisingr,   r-   r.   r/   rt   c               $    V ^8  d   QhRRRRRR/# r4   r   )r   s   "r   r   7test_roy_grok_reauth_is_protected.<locals>.__annotate__o   s&     S SV S S4 Sr   c                     \        R 4      h)z2must not start device login for protected roy-grokr:   r<   s   *,r   r=   /test_roy_grok_reauth_is_protected.<locals>.boomo   s    QRRr   %grok_auth_operation.start_device_codefailurer   rG   r   rH   N	protectedr|   r}   rK   z%(py10)srM   py13py16py18z%(py20)spy20zassert %(py23)spy23rO   r   is not)z3%(py5)s
{%(py5)s = %(py3)s.message
} is not %(py8)sin)z3%(py13)s in %(py18)s
{%(py18)s = %(py16)s.message
})delenvr%   r   r   rT   r   rV   rU   r   reauthenticater1   rX   rY   r]   r;   r^   messageappend_format_boolop)r(   r)   rb   rc   rL   rd   re   r=   eventser   rg   r   rk   ri   rf   r   rl   r   @py_assert12@py_assert15@py_assert17@py_assert14rj   rn   @py_format19@py_format21@py_format22@py_format24s   &&                           r   !test_roy_grok_reauth_is_protectedr   b   s   8%HfD]*K[;./ %%$H
 
8	$B(([;5N(OGS ?F"##G,-F"#FqFFF2#	{2{22222#222#222{22222222M!9MMDMD(MM[MF1IMI<M<MM[<M-MMMMMDMMM9MMMMMMDMMMMMMMMM[<MMMM[MMMIMMM<MMMMMMMMMMMMMMMMMM $s   .Lc               $    V ^8  d   QhRRRRRR/# r'   r   )r   s   "r   r   r   x   s$     #: #:#:!3#:	#:r   c                  a ^ RI HoHp V R,          pV R,          pVR,          p\        V4       VP	                  4       p\        V\        P                  VR7      p\        V4      pR V3R llp	R R	 lp
VP                  VR
V	4       VP                  VRV
4       VP                  \        \        VR7      pVP                  R,          pVP                  q! 4       qV8H  q'       Eg   \        P                  ! RV3RW34      RR\        P                   ! 4       9   g   \        P"                  ! V4      '       d   \        P$                  ! V4      MRR\        P$                  ! V4      R\        P$                  ! V4      RR\        P                   ! 4       9   g   \        P"                  ! V4      '       d   \        P$                  ! V4      MR/,          pRRV/,          p\'        \        P(                  ! V4      4      hR;p;rVP*                  q! 4       q\        8H  q'       Eg"   \        P                  ! RV3RV\        34      RR\        P                   ! 4       9   g   \        P"                  ! V4      '       d   \        P$                  ! V4      MRR\        P$                  ! V4      R\        P$                  ! V4      RR\        P                   ! 4       9   g!   \        P"                  ! \        4      '       d   \        P$                  ! \        4      MR/,          pRRV/,          p\'        \        P(                  ! V4      4      hR;p;rR# )r   )GrokOAuthAuthErrorGrokOAuthSessionr,   r-   r.   r/   c               (    V ^8  d   QhRRRRRRRR/# )r
   selfr   urlstraccessr   dictr   )r   s   "r   r   Htest_import_identity_never_refreshes_on_auth_error.<locals>.__annotate__   s)     2 2( 2s 2C 2D 2r   c                   < ? ??S! R 4      h)zsimulated 401r   )r   r   r   r   s   &&&r   	auth_failEtest_import_identity_never_refreshes_on_auth_error.<locals>.auth_fail   s    #v 11r   c               (    V ^8  d   QhRRRRRRRR/# )r
   r   r   r5   r6   r7   r   r   r   )r   s   "r   r   r      s*     ? ?+ ?V ? ?SW ?r   c                    ? \        R 4      h)zimport must not refresh tokensr:   )r   r5   r7   s   &*,r   refresh_boomHtest_import_identity_never_refreshes_on_auth_error.<locals>.refresh_boom   s    =>>r   	_get_json_refresh_if_neededr@   rD   rE   rF   rG   rH   rI   rJ   rK   NrL   r   rO   rQ   rR   )
grok_oauthr   r   r%   rS   r   r   rT   r   rU   rV   r   rW   rX   rY   rZ   r[   r\   r]   r;   r^   r_   )r(   r)   r   rb   rc   rC   rI   rL   rd   r   r   re   rE   rf   rg   rh   ri   rj   r   s   &&                @r   2test_import_identity_never_refreshes_on_auth_errorr   x   s    @fD]*K+K[!%%'H %%$H
 
8	$B2 2? (+yA(*>M(( ! ) G
 +-D??(?((((((((((((4((((4(((?(((((((((((((((((((((  9 "9&999999"&9999999899998999 999"999999&99999&999999999r   c               $    V ^8  d   QhRRRRRR/# )r
   r)   r*   r(   r   r   r   r   )r   s   "r   r   r      s$     *8 *8:L *8X\ *8ae *8r   c                B
   \        VR ,          \        P                  VR,          R7      p\        V4      pV P	                  RR 4       V P	                  RR 4       V P	                  RR 4       . pVP                  R	4       EF  pVP                  VP                  4       VP                  R
8X  g   K2  VP                  pRqvVJq'       g   \        P                  ! RV3RWg34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R\        P                  ! V4      /,          p	RRV	/,          p
\        \        P                   ! V
4      4      hR;p;rRqP                  qwP"                  qV9   q'       g   \        P                  ! RV3R W34      R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R\        P                  ! V4      /,          p
RRV
/,          p\        \        P                   ! V4      4      hR;p;p;r|VP$                  pRqvVJ q'       g   \        P                  ! R!V3R"Wg34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R\        P                  ! V4      /,          p	RRV	/,          p
\        \        P                   ! V
4      4      hR;p;rEK  	  . R#OqV8H  qf'       g   \        P                  ! R$V3R%WM34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pRRV/,          p	\        \        P                   ! V	4      4      hR;rmVP'                  4       pR V 4       p\)        V4      q'       g   RRR\        P                  ! 4       9   g!   \        P                  ! \(        4      '       d   \        P                  ! \(        4      MRR\        P                  ! V4      R\        P                  ! V4      /,          p\        \        P                   ! V4      4      hR;rhR# )&r,   r-   r/   r   c                     R RRRRRRRR^R	^</# )
device_codedev	user_codeABCDverification_uriz#https://accounts.x.ai/oauth2/deviceverification_uri_completez2https://accounts.x.ai/oauth2/device?user_code=ABCDinterval
expires_inr   r   r   r   <lambda>:test_add_emits_prompt_ready_then_success.<locals>.<lambda>   s'    5 E')]"
r   z$grok_auth_operation.poll_device_codec                    R RRRRR/# )access_tokenz
access-newr   zrefresh-newr   i  r   )_devices   &r   r   r      s    L]$
r   r?   c                    R RRR/# )r   znew@example.comprincipalIdzp-newr   )r   r7   s   &,r   r   r      s    *;]G Tr   new-grokprompt_readyNrD   eventrF   r}   zassert %(py7)sr~   r   r   r|   zassert %(py9)sr   kindsassert %(py5)sc              3  >   "   T F  qP                   R 8H  x  K  	  R# 5i)r   N)rB   ).0as   & r   	<genexpr>;test_add_emits_prompt_ready_then_success.<locals>.<genexpr>   s     7hww*$hs   z,assert %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
}anyrG   r   )z2%(py2)s
{%(py2)s = %(py0)s.prompt
} is not %(py5)sr   )zL%(py1)s in %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.prompt
}.raw_text
})is)z/%(py2)s
{%(py2)s = %(py0)s.session
} is %(py5)s)startedr   successrO   z%(py0)s == %(py3)s)r   r   rT   r   rU   addr   r1   promptrX   rY   rZ   r[   r\   r]   r;   r^   raw_textsessionr   r   )r)   r(   rL   rd   r   r   rf   r   rg   @py_format6@py_format8r   r   r   r   @py_format4accountsrk   s   &&                r   (test_add_emits_prompt_ready_then_successr      s   F" %%!M1H
 
8	$B/	

 .	
 7T
 E
#UZZ ::'<<+t+t+++++<++++++5++++5+++<+++t++++++++2\\222222222262226222222U2222U222\222222222222==(D(D(((((=((((((5((((5(((=(((D(((((((( $ ;:::::::5::::::5::::5::::::::::::}}H7h773777777777737777377777777777777r   c                   V ^8  d   QhRR/# )r
   r   r   r   )r   s   "r   r   r      s      D r   c            	     L   \         P                  ! R RR^2/RR^d/RR//4      w  r^2q V8H  q3'       g   \        P                  ! RV3RW34      RR\        P
                  ! 4       9   g   \        P                  ! V 4      '       d   \        P                  ! V 4      MRR\        P                  ! V4      /,          pR	R
V/,          p\        \        P                  ! V4      4      hR;r2Rq!VJq3'       g   \        P                  ! RV3RW34      RR\        P
                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pR	R
V/,          p\        \        P                  ! V4      4      hR;r2R# )configusedvalmonthlyLimitbillingPeriodEndz2026-08-01T00:00:00+00:00rD   percentr|   r   r}   NresetrO   r   r   )z%(py0)s is not %(py3)s)
r   _parse_billingrX   rY   rZ   r[   r\   r]   r;   r^   )r   r   r   rf   r   r   s         r   *test_health_maps_monthly_to_secondary_onlyr      s    %44"$?	
NG b=777b555r   )
__future__r   builtinsrZ   _pytest.assertion.rewrite	assertionrewriterX   r!   r#   pathlibr   ru   account_registryr   r   r   grok_auth_operationr   grok_health_clientr   r%   rp   ry   r   r   r   r   r   r   r   r   <module>r     sQ    "    	   V V 1 /(3@-B$N,#:L*8Zr   