1# Copyright 2020 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14import pytest 15 16from google.auth import jwt 17import google.oauth2.id_token 18 19 20def test_fetch_id_token(http_request): 21 audience = "https://pubsub.googleapis.com" 22 token = google.oauth2.id_token.fetch_id_token(http_request, audience) 23 24 _, payload, _, _ = jwt._unverified_decode(token) 25 assert payload["aud"] == audience 26