Ë
    ûûàgà  ã                   ó  — d dl Z d dlmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d d	lmZmZ d
dlmZ  G d„ dee«      Z edddii¬«       G d„ de«      «       Z eddddiii¬«       G d„ de«      «       Zy)é    N)Úparse_qsÚurlparse)ÚTestCase)Úoverride_settings)Úreverse)Ú	urlencode)ÚSocialAccount)ÚOAuth2TestsMixin)ÚMockedResponseÚmocked_responseé   )ÚShopifyProviderc                   ó>   — e Zd Zej                  Zd„ Zdd„Zd„ Zd„ Z	y)ÚShopifyTestsc                 óf  — t        | j                  j                  dz   «      }| j                  |d   d   j	                  |«      d«       | j                  |¬«      }t        t        d|ddi«      |«      5  | j                  j                  |d|d	   d   dd
œ«      }d d d «       |S # 1 sw Y   |S xY w)NÚ	_callbackÚredirect_urir   )Úwith_refresh_tokenéÈ   zcontent-typezapplication/jsonÚtestÚstate)Úcoder   Úshop)
r   ÚproviderÚidÚassertGreaterÚfindÚget_login_response_jsonr   r   ÚclientÚget)ÚselfÚqÚrespÚ	resp_mockr   Úcomplete_urlÚresponse_jsons          úk/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/allauth/socialaccount/providers/shopify/tests.pyÚ_complete_shopify_loginz$ShopifyTests._complete_shopify_login   sÂ   € Ü˜tŸ}™}×/Ñ/°+Ñ=Ó>ˆØ×Ñ˜1˜^Ñ,¨QÑ/×4Ñ4°\ÓBÀAÔFØ×4Ñ4Ø1ð 5ó 
ˆô Ü˜3 °Ð@RÐ/SÓTØó
ñ 	ð —;‘;—?‘?Øà"Ø˜w™Z¨™]Ø"ñóˆD÷		ð ˆ÷	ð ˆús   Á5'B&Â&B0c                 óJ  — t        | j                  j                  dz   «      dz   t        |ddœ«      z   }| j                  j                  |«      }| j                  |j                  d«       t        |d   «      }t        |j                  «      }| j                  ||||«      }|S )NÚ_loginú?r   ©Úprocessr   i.  Úlocation)r   r   r   r   r   ÚpostÚassertEqualÚstatus_coder   r   Úqueryr(   )r!   r$   r-   r   Úurlr#   Úpr"   s           r'   ÚloginzShopifyTests.login'   s�   € ä�D—M‘M×$Ñ$ xÑ/Ó0Øñä G°VÑ<Ó=ñ>ð 	ð
 �{‰{×Ñ Ó$ˆØ×Ñ˜×)Ñ)¨3Ô/Ü�T˜*Ñ%Ó&ˆÜ�Q—W‘WÓˆØ×+Ñ+¨A¨t°YÐ@RÓSˆØˆó    c                 ó   — t        dd«      S )Nr   z´
        {
            "shop": {
                "id": "1234566",
                "name": "Test Shop",
                "email": "email@example.com"
            }
        }
        )r   ©r!   s    r'   Úget_mocked_responsez ShopifyTests.get_mocked_response4   s   € ÜØðó
ð 	
r6   c                  ó   — y)Nzemail@example.com© r8   s    r'   Úget_expected_to_strz ShopifyTests.get_expected_to_strB   s   € Ø"r6   N©r5   T)
Ú__name__Ú
__module__Ú__qualname__r   r   Úprovider_idr(   r5   r9   r<   r;   r6   r'   r   r      s!   „ Ø!×$Ñ$€Kòó(ò
ó#r6   r   ÚshopifyÚIS_EMBEDDEDT)ÚSOCIALACCOUNT_PROVIDERSc                   ó   — e Zd ZdZdd„Zy)ÚShopifyEmbeddedTestszß
    Shopify embedded apps (that run within an iFrame) require a JS (not server)
    redirect for starting the oauth2 process.

    See Also:
    https://help.shopify.com/api/sdks/embedded-app-sdk/getting-started#oauth
    c                 óŽ  — | j                   j                  t        | j                  j                  dz   «      dz   t        |ddœ«      z   «      }| j                  |j                  d«       |j                  j                  d«      }| j                  d|v dj                  |«      «       | j                  |j                  d	«       | j                  d
|v xr d|v dj                  |«      «       t        |j                  d«      d   j                  d«      d   «      }t        |j                   «      }| j#                  ||||«      }|S )Nr*   r+   r   r,   r   Úutf8Úscriptz(Content missing script tag. [Actual: {}]z4Redirect JS must be allowed to run in Shopify iframez<!DOCTYPE html><html><head>z</head><body></body></html>z-Expected standard HTML skeleton. [Actual: {}]z
;</script>r   zlocation.href = "r   )r   r/   r   r   r   r   r0   r1   ÚcontentÚdecodeÚ
assertTrueÚformatÚxframe_options_exemptr   Úsplitr   r2   r(   )r!   r$   r-   r   r#   Úactual_contentr4   r"   s           r'   r5   zShopifyEmbeddedTests.loginP   s=  € Ø�{‰{×ÑÜ�D—M‘M×$Ñ$ xÑ/Ó0Øñä G°VÑ<Ó=ñ>ó
ˆð
 	×Ñ˜×)Ñ)¨3Ô/ØŸ™×,Ñ,¨VÓ4ˆØ�‰Ø˜Ð&Ø6×=Ñ=¸nÓMô	
ð 	�‰Ø×&Ñ&ØBô	
ð 	�‰Ø)¨^Ð;ò @Ø-°Ð?Ø;×BÑBÀ>ÓRô	
ô
 Ø× Ñ  Ó.¨qÑ1×7Ñ7Ð8KÓLÈQÑOó
ˆô �Q—W‘WÓˆØ×+Ñ+¨A¨t°YÐ@RÓSˆØˆr6   Nr=   )r>   r?   r@   Ú__doc__r5   r;   r6   r'   rF   rF   F   s   „ ñôr6   rF   ÚAUTH_PARAMSzgrant_options[]zper-userc                   ó:   — e Zd ZdZdd„Z eddd¬«      d„ «       Zy)ÚShopifyPerUserAccessTestsaQ  
    Shopify has two access modes, offline (the default) and online/per-user.
    Enabling 'online' access should cause all-auth to tie the logged in
    Shopify user to the all-auth account (rather than the shop as a whole).

    See Also:
    https://help.shopify.com/api/getting-started/authentication/
    oauth#api-access-modes
    Tc           
      óV   — ddddddddd	d
œdœ}|rd|d<   t        j                  |«      S )NÚtestaczwrite_orders,read_customersiQ Úwrite_orderséC±Ë5ÚJonÚSmithújon@example.comT)r   Ú
first_nameÚ	last_nameÚemailÚaccount_owner)Úaccess_tokenÚscopeÚ
expires_inÚassociated_user_scopeÚassociated_userÚtestrfÚrefresh_token)ÚjsonÚdumps)r!   r   Úresponse_datas      r'   r   z1ShopifyPerUserAccessTests.get_login_response_json}   sG   € à$Ø2ØØ%3àØ#Ø$Ø*Ø!%ñ ñ
ˆñ Ø-5ˆM˜/Ñ*ä�z‰z˜-Ó(Ð(r6   )ÚSOCIALACCOUNT_AUTO_SIGNUPÚSOCIALACCOUNT_EMAIL_REQUIREDÚACCOUNT_EMAIL_REQUIREDc                 ó4  — | j                  «       }| j                  |«      }| j                  |dd¬«       t        j                  j                  | j                  j                  d¬«      j                  «       }| j                  |«       | j                  d|j                  v «       | j                  |j                  j                  d«       | j                  |j                  j                  d«       | j                  |j                  j                   d	«       y )
Nz/accounts/profile/F)Úfetch_redirect_responserX   )r   Úuidrd   r[   rY   rZ   )r9   r5   ÚassertRedirectsr	   ÚobjectsÚfilterr   r   ÚfirstÚassertIsNotNonerL   Ú
extra_datar0   Úuserr^   r\   r]   )r!   Ú
resp_mocksr#   Úsocial_accounts       r'   Útest_associated_userz.ShopifyPerUserAccessTests.test_associated_user�   së   € ð ×-Ñ-Ó/ˆ
Ø�z‰z˜*Ó%ˆØ×Ñ˜TÐ#7ÐQVÐÔWä&×.Ñ.×5Ñ5Ø—]‘]×%Ñ%Øð 6ó 
÷ ‰%‹'ð 	ð 	×Ñ˜^Ô,Ø�‰Ð)¨^×-FÑ-FÐFÔGà×Ñ˜×,Ñ,×2Ñ2Ð4EÔFØ×Ñ˜×,Ñ,×7Ñ7¸Ô?Ø×Ñ˜×,Ñ,×6Ñ6¸Õ@r6   N)T)r>   r?   r@   rQ   r   r   ry   r;   r6   r'   rT   rT   m   s0   „ ñó)ñ& Ø"&Ø%)Ø#ôñ
Aóñ
Ar6   rT   )rg   Úurllib.parser   r   Údjango.testr   Údjango.test.utilsr   Údjango.urlsr   Údjango.utils.httpr   Úallauth.socialaccount.modelsr	   Úallauth.socialaccount.testsr
   Úallauth.testsr   r   r   r   r   rF   rT   r;   r6   r'   ú<module>r‚      s—   ðÛ ß +å  Ý /Ý Ý 'å 6Ý 8ß 9å %ô3#Ð# Xô 3#ñl ¨I¸ÀtÐ7LÐ+MÔNô#˜<ó #ó Oð#ñL à�MÐ$5°zÐ#BÐCðôô
1A ó 1Aóñ
1Ar6   