+
    5mj  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Ht ]	P                  P                  ^ ]! ]! ]4      P%                  4       P&                  ^,          4      4       ^ RIHtHtHtHtHt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 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)Callable)CredentialAuthoritycredentials_fingerprintidentity_pin_pathpin_account_uuidpinned_account_uuidresolve_credentialsc               (    V ^8  d   QhRRRRRRRR/# )   pathr   access_tokenstrrefresh_tokenreturnNone )formats   "g/home/user/overdeck-private-tests/workstation-ai-broad/modules/systray/tests/test_claude_credentials.py__annotate__r      s(      T  S T     c                    V P                   P                  R R R7       V P                  \        P                  ! RRVRVR^ //4      RR7       R# )	Tparentsexist_okclaudeAiOauthaccessTokenrefreshToken	expiresAtutf-8encodingN)parentmkdir
write_textjsondumps)r   r   r   s   &&&r   _write_credentialsr(      sW    KKdT2OO

!<"M"	
   r   c               $    V ^8  d   QhRRRRRR/# )r   homer   account_uuidr   r   r   r   )r   s   "r   r   r   $   s!     ) )$ )c )d )r   c                B    V P                  R R R7       \        W4       R# )Tr   N)r$   r   )r*   r+   s   &&r   _write_identityr-   $   s    JJtdJ+T(r   c                    V ^8  d   QhRRRR/# )r   r+   r   r   zCallable[[Path], str | None]r   )r   s   "r   r   r   )   s     & &s &/K &r   c                   a  V 3R  l# )c                   < S# Nr   )_pathr+   s   &r   <lambda>&_live_token_owned_by.<locals>.<lambda>*   s    r   r   )r+   s   fr   _live_token_owned_byr5   )   s	    %%r   c                    V ^8  d   QhRRRR/# )r   r2   r   r   z
str | Noner   )r   s   "r   r   r   -   s     N N N* Nr   c                    \        R 4      h)z1the live credentials file must not be probed here)AssertionErrorr2   s   &r   _never_probedr:   -   s    
L
MMr   c                    V ^8  d   QhRRRR/# r   tmp_pathr   r   r   r   )r   s   "r   r   r   1   s     & &PT &Y] &r   c                   V R ,          pV R,          p\        VR4       \        VR,          RR4       \        VR,          RR4       \        W\        R4      R7      pVP                  pRqRV,          qdV8H  qw'       Eg   \
        P                  ! RV3RWF3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                  ! V4      '       d   \
        P                  ! V4      MRR\
        P                  ! V4      /,          pRRV/,          p	\        \
        P                  ! V	4      4      hR;p;p;rVVP                  p\        P                  qTVJ qw'       Eg   \
        P                  ! RV3RWE3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      /,          p
RRV
/,          p\        \
        P                  ! V4      4      hR;p;ruVP                   pRqVJ qw'       g   \
        P                  ! RV3RWL3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;r|R# )accountlive	same-uuid.credentials.jsonownown-refreshlive-refreshidentifypy0resolvedpy2py4	live_homepy6assert %(py9)spy9Nr   assert %(py8)spy8Tpy5assert %(py7)spy7==z8%(py2)s
{%(py2)s = %(py0)s.path
} == (%(py4)s / %(py6)s)iszU%(py2)s
{%(py2)s = %(py0)s.authority
} is %(py6)s
{%(py6)s = %(py4)s.VENDOR_MANAGED
})z1%(py2)s
{%(py2)s = %(py0)s.read_only
} is %(py5)s)r-   r(   r
   r5   r   
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprr8   _format_explanation	authorityr   VENDOR_MANAGED	read_only)r=   account_homerL   rI   @py_assert1@py_assert5@py_assert7@py_assert3@py_format8@py_format10@py_format7@py_format9@py_assert4@py_format6s   &             r   Atest_the_live_grant_wins_when_the_token_itself_names_this_accountrp   1   s   i'L6!IL+.|&995-Py#66O"*>{*KH ==;(;;(;;;;;;;;;=;;;;;;8;;;;8;;;=;;;;;;I;;;;I;;;(;;;;;;;;;C!4!C!CC!CCCCCCCCCCCC8CCCC8CCCCCCCCC!4CCCC!4CCC!CCCCCCCCC%%%%%%%%%%%%%8%%%%8%%%%%%%%%%%%%%r   c                    V ^8  d   QhRRRR/# r<   r   )r   s   "r   r   r   A   s     D D4 DTX Dr   c                   V R ,          pV R,          p\        VR4       \        VR,          RR4       \        VR,          RR4       \        W\        R4      R7      pVP                  pRqQV,          qdV8H  qw'       Eg   \
        P                  ! RV3RWF3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                  ! V4      '       d   \
        P                  ! V4      MRR\
        P                  ! V4      /,          pRRV/,          p	\        \
        P                  ! V	4      4      hR;p;p;rVVP                  p\        P                  qTVJ qw'       Eg   \
        P                  ! RV3RWE3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      /,          p
RRV
/,          p\        \
        P                  ! V4      4      hR;p;ruR# )r?   r@   rA   rB   rC   rD   rE   z
other-uuidrF   rH   rI   rJ   rK   re   rM   rN   rO   Nr   rP   rQ   rU   rW   rX   rZ   )r-   r(   r
   r5   r   r[   r\   r]   r^   r_   r`   r8   ra   rb   r   rc   r=   re   rL   rI   rf   rg   rh   ri   rj   rk   rl   rm   s   &           r   <test_a_live_grant_belonging_to_another_account_is_never_readrt   A   s   i'L6!IL+.|&995-Py#66O"*>|*LH ==>+>>+>>>>>>>>>=>>>>>>8>>>>8>>>=>>>>>>L>>>>L>>>+>>>>>>>>>C!4!C!CC!CCCCCCCCCCCC8CCCC8CCCCCCCCC!4CCCC!4CCC!CCCCCCCCCr   c                    V ^8  d   QhRRRR/# r<   r   )r   s   "r   r   r   P   s     	D 	DT 	Dd 	Dr   c                   V R ,          pV R,          p\        VR4       \        VR,          RR4       \        WR R7      pVP                  pRqQV,          qdV8H  qw'       Eg   \        P
                  ! RV3RWF3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                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pRRV/,          p	\        \        P                  ! V	4      4      hR;p;p;rVVP                  p\        P                  qTVJ qw'       Eg   \        P
                  ! RV3RWE3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      /,          p
RRV
/,          p\        \        P                  ! V4      4      hR;p;ruR# )r?   r@   rA   rB   rE   c                    R # r1   r   r9   s   &r   r3   @test_an_unverified_live_grant_is_never_claimed.<locals>.<lambda>V   s    SWr   rF   rH   rI   rJ   rK   re   rM   rN   rO   Nr   rP   rQ   rU   rW   rX   rZ   r-   r(   r
   r   r[   r\   r]   r^   r_   r`   r8   ra   rb   r   rc   rs   s   &           r   .test_an_unverified_live_grant_is_never_claimedrz   P   s   i'L6!IL+.y#66O"<EWXH==>+>>+>>>>>>>>>=>>>>>>8>>>>8>>>=>>>>>>L>>>>L>>>+>>>>>>>>>C!4!C!CC!CCCCCCCCCCCC8CCCC8CCCCCCCCC!4CCCC!4CCC!CCCCCCCCCr   c                    V ^8  d   QhRRRR/# r<   r   )r   s   "r   r   r   \   s      	D 	DSW 	D\` 	Dr   c                   V R ,          pV R,          pVP                  4        \        VR,          RR4       \        W\        R7      pVP                  pRqQV,          qdV8H  qw'       Eg   \
        P                  ! RV3RWF3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                  ! V4      '       d   \
        P                  ! V4      MR	R
\
        P                  ! V4      /,          pRRV/,          p	\        \
        P                  ! V	4      4      hR;p;p;rVVP                  p\        P                  qTVJ qw'       Eg   \
        P                  ! RV3RWE3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      /,          p
RRV
/,          p\        \
        P                  ! V4      4      hR;p;ruR# )r?   r@   rB   rE   rF   rH   rI   rJ   rK   re   rM   rN   rO   Nr   rP   rQ   rU   rW   rX   rZ   )r$   r(   r
   r:   r   r[   r\   r]   r^   r_   r`   r8   ra   rb   r   rc   rs   s   &           r   Dtest_an_account_without_its_own_identity_never_claims_the_live_grantr}   \   s   i'L6!Iy#66O"<]SH==>+>>+>>>>>>>>>=>>>>>>8>>>>8>>>=>>>>>>L>>>>L>>>+>>>>>>>>>C!4!C!CC!CCCCCCCCCCCC8CCCC8CCCCCCCCC!4CCCC!4CCC!CCCCCCCCCr   c                    V ^8  d   QhRRRR/# r<   r   )r   s   "r   r   r   h   s     
D 
D$ 
D4 
Dr   c                   V R ,          pV R,          p\        VR4       \        VR,          RR4       \        VR,          RR4       \        W\        R7      pVP                  pRqQV,          qdV8H  qw'       Eg   \
        P                  ! RV3RWF3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                  ! V4      '       d   \
        P                  ! V4      MRR\
        P                  ! V4      /,          pRRV/,          p	\        \
        P                  ! V	4      4      hR;p;p;rVVP                  p\        P                  qTVJ qw'       Eg   \
        P                  ! RV3RWE3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      /,          p
RRV
/,          p\        \
        P                  ! V4      4      hR;p;ruR# )r?   r@   rA   rB   rC   rD    rF   rH   rI   rJ   rK   re   rM   rN   rO   Nr   rP   rQ   rU   rW   rX   rZ   )r-   r(   r
   r:   r   r[   r\   r]   r^   r_   r`   r8   ra   rb   r   rc   rs   s   &           r   3test_an_empty_live_credentials_file_is_never_probedr   h   s   i'L6!IL+.|&995-Py#66B?"<]SH==>+>>+>>>>>>>>>=>>>>>>8>>>>8>>>=>>>>>>L>>>>L>>>+>>>>>>>>>C!4!C!CC!CCCCCCCCCCCC8CCCC8CCCCCCCCC!4CCCC!4CCC!CCCCCCCCCr   c                    V ^8  d   QhRRRR/# r<   r   )r   s   "r   r   r   u   s     D D4 DD Dr   c                x   V R ,          p\        VR4       \        VR,          RR4       \        W4      pVP                  pRqAV,          qSV8H  qf'       Eg   \        P
                  ! RV3RW53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                  ! V4      '       d   \        P                  ! V4      MRR	\        P                  ! V4      /,          pR
RV/,          p\        \        P                  ! V4      4      hR;p;p;rEVP                  p\        P                  qCVJ qf'       Eg   \        P
                  ! RV3RW43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      /,          p	RRV	/,          p
\        \        P                  ! V
4      4      hR;p;rdR# )r@   rA   rB   r   rH   rI   rJ   rK   rL   rM   rN   rO   Nr   rP   rQ   rU   rW   rX   rZ   ry   )r=   rL   rI   rf   rg   rh   ri   rj   rk   rl   rm   s   &          r   4test_account_home_that_is_the_live_home_is_read_onlyr   u   su   6!II{+y#66B?"98H==;(;;(;;;;;;;;;=;;;;;;8;;;;8;;;=;;;;;;I;;;;I;;;(;;;;;;;;;C!4!C!CC!CCCCCCCCCCCC8CCCC8CCCCCCCCC!4CCCC!4CCC!CCCCCCCCCr   c                    V ^8  d   QhRRRR/# r<   r   )r   s   "r   r   r      s      F FSW F\` Fr   c                2	   V R ,          p\        VRR4       \        V4      pVP                  \        P                  ! RRRRRRR//4      RR	7       \        V4      q3V8H  qD'       EgU   \
        P                  ! RV3RW234      R
R\        P                  ! 4       9   g!   \
        P                  ! \        4      '       d   \
        P                  ! \        4      M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                  ! V4      '       d   \
        P                  ! V4      MR/,          pRRV/,          p\        \
        P                  ! V4      4      hR;r4\        VRR4       \        V4      q3V8g  qD'       EgU   \
        P                  ! RV3RW234      R
R\        P                  ! 4       9   g!   \
        P                  ! \        4      '       d   \
        P                  ! \        4      M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                  ! V4      '       d   \
        P                  ! V4      MR/,          pRRV/,          p\        \
        P                  ! V4      4      hR;r4Rq0V,          p\        V4      pRqVJ q'       Eg3   \
        P                  ! R V	3R!Wx34      R
R\        P                  ! 4       9   g!   \
        P                  ! \        4      '       d   \
        P                  ! \        4      MRRR\        P                  ! 4       9   g   \
        P                  ! V 4      '       d   \
        P                  ! V 4      MRR\
        P                  ! V4      R\
        P                  ! V4      R\
        P                  ! V4      /,          p
RRV
/,          p\        \
        P                  ! V4      4      hR;p;p;p;rR# )"rB   accessrefreshr   r   r   r   i  r    r!   rH   r   py1r   py3rR   beforerS   rT   Nz
access-newzrefresh-newzmissing.jsonr=   rM   rO   zassert %(py11)spy11rU   )z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py5)s)!=)z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} != %(py5)srX   )z<%(py6)s
{%(py6)s = %(py0)s((%(py1)s / %(py3)s))
} is %(py9)s)r(   r   r%   r&   r'   r[   r\   r]   r^   r_   r`   r8   ra   )r=   r   r   @py_assert2rn   ro   rj   rg   @py_assert8rh   rk   @py_format12s   &           r   Dtest_fingerprint_changes_with_the_grant_and_survives_unrelated_editsr      s   ))DtXy1$T*FOO

!8"I"	
    #4(2F22222(222222"2222"2222222422224222(222222F2222F22222222t\=9"4(2F22222(222222"2222"2222222422224222(222222F2222F22222222.<En#<E"#<=EEEEEEE=EEEEEE"EEEE"EEEEEEE8EEEE8EEEnEEE=EEEEEEEEEEEEr   c                    V ^8  d   QhRRRR/# r<   r   )r   s   "r   r   r      s     ? ?RV ?[_ ?r   c                   V R ,          pV R,          pVP                  4        VR,          P                  \        P                  ! RRR//4      RR7       \	        VR,          R	R
4       \	        VR,          RR4       \        W\        R4      R7      pVP                  pRqQV,          qdV8H  qw'       Eg   \        P                  ! RV3RWF3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                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pRRV/,          p	\        \        P                  ! V	4      4      hR;p;p;rVR# )r?   r@   z.claude.jsonoauthAccountaccountUuidzlive-owner-uuidr    r!   rB   rC   rD   rE   rF   rH   rI   rJ   rK   re   rM   rN   rO   NrU   rW   )r$   r%   r&   r'   r(   r
   r5   r   r[   r\   r]   r^   r_   r`   r8   ra   
r=   re   rL   rI   rf   rg   rh   ri   rj   rk   s
   &         r   Ctest_a_poisoned_claude_json_without_a_pin_never_wins_the_live_grantr      s2   i'L6!IN"..

N]4E$FGH /  |&995-Py#66O"*>?P*QH ==>+>>+>>>>>>>>>=>>>>>>8>>>>8>>>=>>>>>>L>>>>L>>>+>>>>>>>>>r   c                    V ^8  d   QhRRRR/# r<   r   )r   s   "r   r   r      s     < < <QU <r   c                X   V R ,          pV R,          pVP                  4        \        VR4       \        VR,          RR4       \        VR,          RR4       \        W\	        R4      R7      pVP
                  pRqRV,          qdV8H  qw'       Eg   \        P                  ! RV3RWF3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                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pRRV/,          p	\        \        P                  ! V	4      4      hR;p;p;rVR# )r?   r@   rA   rB   rC   rD   rE   rF   rH   rI   rJ   rK   rL   rM   rN   rO   NrU   rW   )r$   r   r(   r
   r5   r   r[   r\   r]   r^   r_   r`   r8   ra   r   s
   &         r   9test_a_pin_matching_the_live_identity_wins_the_live_grantr      s   i'L6!I\;/|&995-Py#66O"*>{*KH ==;(;;(;;;;;;;;;=;;;;;;8;;;;8;;;=;;;;;;I;;;;I;;;(;;;;;;;;;r   c                    V ^8  d   QhRRRR/# r<   r   )r   s   "r   r   r      s     = =$ =4 =r   c                   V R ,          pVP                  4        \        VR4       \        VR4       \        V4      pRq2V8H  qD'       Eg   \        P                  ! RV3RW#34      RR\
        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      M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R	R
V/,          p\        \        P                  ! V4      4      hR;p;rCR# )r?   z
first-uuidzsecond-uuidrH   r	   r   re   r   rM   rP   rQ   NrU   )z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)s)r$   r   r	   r[   r\   r]   r^   r_   r`   r8   ra   r=   re   r   rg   rn   rl   rm   s   &      r   #test_pin_account_uuid_is_write_oncer      s    i'L\<0\=1|,<<<<<<<,<<<<<<<<<<<<<<<<<|<<<<|<<<,<<<<<<<<<<<r   c                    V ^8  d   QhRRRR/# r<   r   )r   s   "r   r   r      s     5 54 5D 5r   c                   V R ,          pVP                  4        \        V4      P                  RRR7       \        V4      pRq2VJ qD'       Eg   \        P
                  ! RV3RW#34      RR\        P                  ! 4       9   g!   \        P                  ! \        4      '       d   \        P                  ! \        4      M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RRV/,          p\        \        P                  ! V4      4      hR;p;rCR# )r?   znot jsonr    r!   NrH   r	   r   re   r   rM   rP   rQ   rX   )z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} is %(py6)s)r$   r   r%   r	   r[   r\   r]   r^   r_   r`   r8   ra   r   s   &      r   ,test_a_malformed_pin_file_resolves_to_no_pinr      s    i'Ll#..zG.L|,4444444,44444444444444444|4444|444,44444444444r   )*
__future__r   builtinsr]   _pytest.assertion.rewrite	assertionrewriter[   r&   syspathlibr   typingr   r   insertr   __file__resolver   claude_credentialsr   r   r   r   r	   r
   r(   r-   r5   r:   rp   rt   rz   r}   r   r   r   r   r   r   r   r   r   r   <module>r      s    "    
   3tH~--/77:; <  )
&N& D	D	D
DDF0?$<=5r   