コード例 #1
0
    def test_encode_full_payload(self):
        token = ClientCapabilityToken("AC123", "XXXXX")
        token.allow_event_stream(foobar="hey")
        token.allow_client_incoming("andy")

        event_uri = "scope:stream:subscribe?params=foobar%3Dhey&path=%2F2010-04-01%2FEvents"
        incoming_uri = "scope:client:incoming?clientName=andy"

        self.assertIn(event_uri, token.payload["scope"])
        self.assertIn(incoming_uri, token.payload["scope"])
        self.assertEqual(token.payload['iss'], 'AC123')
        self.assertGreaterEqual(token.payload['exp'], self.now())
コード例 #2
0
    def test_decode(self):
        token = ClientCapabilityToken("AC123", "XXXXX")
        token.allow_client_outgoing("AP123", foobar=3)
        token.allow_client_incoming("andy")
        token.allow_event_stream()

        outgoing_uri = "scope:client:outgoing?appParams=foobar%3D3&appSid=AP123&clientName=andy"
        incoming_uri = "scope:client:incoming?clientName=andy"
        event_uri = "scope:stream:subscribe?path=%2F2010-04-01%2FEvents"

        result = Jwt.from_jwt(token.to_jwt(), "XXXXX")
        scope = result.payload["scope"].split(" ")

        self.assertIn(outgoing_uri, scope)
        self.assertIn(incoming_uri, scope)
        self.assertIn(event_uri, scope)
コード例 #3
0
    def test_events_with_filters(self):
        token = ClientCapabilityToken("AC123", "XXXXX")
        token.allow_event_stream(foobar="hey")

        event_uri = "scope:stream:subscribe?params=foobar%3Dhey&path=%2F2010-04-01%2FEvents"
        assert_equal(token.payload["scope"], event_uri)
コード例 #4
0
    def test_events(self):
        token = ClientCapabilityToken("AC123", "XXXXX")
        token.allow_event_stream()

        event_uri = "scope:stream:subscribe?path=%2F2010-04-01%2FEvents"
        assert_equal(token.payload["scope"], event_uri)