File: test_assertion.py

package info (click to toggle)
microsoft-authentication-library-for-python 1.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,320 kB
  • sloc: python: 8,613; xml: 2,783; sh: 27; makefile: 19
file content (15 lines) | stat: -rw-r--r-- 520 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import json

from msal.oauth2cli import JwtAssertionCreator
from msal.oauth2cli.oidc import decode_part

from tests import unittest


class AssertionTestCase(unittest.TestCase):
    def test_extra_claims(self):
        assertion = JwtAssertionCreator(key=None, algorithm="none").sign_assertion(
            "audience", "issuer", additional_claims={"client_ip": "1.2.3.4"})
        payload = json.loads(decode_part(assertion.split(b'.')[1].decode('utf-8')))
        self.assertEqual("1.2.3.4", payload.get("client_ip"))