File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,55 @@ def test_decode_jwt_payload_succeeds_with_not_before_in_the_future_within_10s_le
139139 sid : decoded . sid ,
140140 } )
141141 end
142+
143+ def test_decode_jwt_payload_coming_from_checkout_ui_extension
144+ payload = @jwt_payload . dup
145+ payload [ :sid ] = nil
146+ jwt_token = JWT . encode ( payload , ShopifyAPI ::Context . api_secret_key , "HS256" )
147+ decoded = ShopifyAPI ::Auth ::JwtPayload . new ( jwt_token )
148+ assert_equal ( payload ,
149+ {
150+ iss : decoded . iss ,
151+ dest : decoded . dest ,
152+ aud : decoded . aud ,
153+ sub : decoded . sub ,
154+ exp : decoded . exp ,
155+ nbf : decoded . nbf ,
156+ iat : decoded . iat ,
157+ jti : decoded . jti ,
158+ sid : decoded . sid ,
159+ } )
160+
161+ assert_equal ( decoded . expire_at , @jwt_payload [ :exp ] )
162+ assert_equal ( "test-shop.myshopify.io" , decoded . shopify_domain )
163+ assert_equal ( "test-shop.myshopify.io" , decoded . shop )
164+ assert_equal ( 1 , decoded . shopify_user_id )
165+ end
166+
167+ def test_decode_jwt_payload_coming_from_checkout_ui_extension_without_user_logged_in
168+ payload = @jwt_payload . dup
169+ payload [ :sid ] = nil
170+ payload [ :sub ] = nil
171+ jwt_token = JWT . encode ( payload , ShopifyAPI ::Context . api_secret_key , "HS256" )
172+ decoded = ShopifyAPI ::Auth ::JwtPayload . new ( jwt_token )
173+ assert_equal ( payload ,
174+ {
175+ iss : decoded . iss ,
176+ dest : decoded . dest ,
177+ aud : decoded . aud ,
178+ sub : decoded . sub ,
179+ exp : decoded . exp ,
180+ nbf : decoded . nbf ,
181+ iat : decoded . iat ,
182+ jti : decoded . jti ,
183+ sid : decoded . sid ,
184+ } )
185+
186+ assert_equal ( decoded . expire_at , @jwt_payload [ :exp ] )
187+ assert_equal ( "test-shop.myshopify.io" , decoded . shopify_domain )
188+ assert_equal ( "test-shop.myshopify.io" , decoded . shop )
189+ assert_nil ( decoded . shopify_user_id )
190+ end
142191 end
143192 end
144193end
You can’t perform that action at this time.
0 commit comments