Skip to content

Commit 6703303

Browse files
author
Sebastian Molenda
committed
expanded test as example
1 parent 5bbc096 commit 6703303

File tree

5 files changed

+164
-102
lines changed

5 files changed

+164
-102
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"version": 1,
3+
"interactions": [
4+
{
5+
"request": {
6+
"method": "POST",
7+
"uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant",
8+
"body": {
9+
"pickle": "gASVKgEAAAAAAABYIwEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsic29tZV9zcGFjZV9pZCI6IDN9LCAiZ3JvdXBzIjoge30sICJ1dWlkcyI6IHt9LCAidXNlcnMiOiB7fSwgInNwYWNlcyI6IHsic29tZV9zcGFjZV9pZCI6IDN9fSwgInBhdHRlcm5zIjogeyJjaGFubmVscyI6IHsic29tZV8qIjogM30sICJncm91cHMiOiB7fSwgInV1aWRzIjoge30sICJ1c2VycyI6IHt9LCAic3BhY2VzIjogeyJzb21lXyoiOiAzfX0sICJtZXRhIjoge30sICJ1dWlkIjogInNvbWVfdXNlcl9pZCJ9fZQu"
10+
},
11+
"headers": {
12+
"host": [
13+
"ps.pndsn.com"
14+
],
15+
"accept": [
16+
"*/*"
17+
],
18+
"accept-encoding": [
19+
"gzip, deflate"
20+
],
21+
"connection": [
22+
"keep-alive"
23+
],
24+
"user-agent": [
25+
"PubNub-Python/10.1.0"
26+
],
27+
"content-type": [
28+
"application/json"
29+
],
30+
"content-length": [
31+
"291"
32+
]
33+
}
34+
},
35+
"response": {
36+
"status": {
37+
"code": 200,
38+
"message": "OK"
39+
},
40+
"headers": {
41+
"Date": [
42+
"Tue, 11 Feb 2025 20:46:28 GMT"
43+
],
44+
"Content-Type": [
45+
"text/javascript; charset=UTF-8"
46+
],
47+
"Transfer-Encoding": [
48+
"chunked"
49+
],
50+
"Connection": [
51+
"keep-alive"
52+
],
53+
"cache-control": [
54+
"no-cache, no-store, must-revalidate"
55+
],
56+
"content-encoding": [
57+
"gzip"
58+
],
59+
"Access-Control-Allow-Credentials": [
60+
"true"
61+
],
62+
"Access-Control-Expose-Headers": [
63+
"*"
64+
]
65+
},
66+
"body": {
67+
"pickle": "gASVKQEAAAAAAAB9lIwGc3RyaW5nlEIWAQAAH4sIAAAAAAAA/1WQTY+CMBiE/8qmZzcBzBrlRuTD1VCzJfJ12ZRScWmhSosKxv++dTcePL2ZeWcyyXMDJVYY2DfQUClxRYENop4QLcAEKMFoq52T51sO842goZ0akFuukAzcq0uaeDzuUI0DvxeJORaWydMpvGQJ5KnFmWPAlrTL6uvhzXxFrIXK48VIAr/W95g70C1TOAgPmWXCmfB0Lo04CqDIktkhb+G5SOL9poJuPl1f9F93ty/+ax+pPEWHpy5W/zmd4YTrPd3HSZl9rjfzGDrSDDtzNhfZ9jpEYv8dLwvxXgbFLmTVh0GYS+tTA+4TIGl3/iEPNs4fmrcQt5pVpxFJhVUvgW0Zxv0XP0RQKE0BAACUcy4="
68+
}
69+
}
70+
}
71+
]
72+
}

tests/integrational/fixtures/native_sync/pam/grant_token_user_space.yaml

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"version": 1,
3+
"interactions": [
4+
{
5+
"request": {
6+
"method": "POST",
7+
"uri": "https://ps.pndsn.com/v3/pam/{PN_KEY_PAM_SUBSCRIBE}/grant",
8+
"body": {
9+
"pickle": "gASVhAEAAAAAAABYfQEAAHsidHRsIjogNjAsICJwZXJtaXNzaW9ucyI6IHsicmVzb3VyY2VzIjogeyJjaGFubmVscyI6IHsic29tZV9jaGFubmVsX2lkIjogMjM5fSwgImdyb3VwcyI6IHsic29tZV9ncm91cF9pZCI6IDV9LCAidXVpZHMiOiB7InNvbWVfdXVpZCI6IDEwNH0sICJ1c2VycyI6IHsic29tZV91dWlkIjogMTA0fSwgInNwYWNlcyI6IHsic29tZV9jaGFubmVsX2lkIjogMjM5fX0sICJwYXR0ZXJucyI6IHsiY2hhbm5lbHMiOiB7InNvbWVfKiI6IDd9LCAiZ3JvdXBzIjogeyJzb21lXyoiOiAxfSwgInV1aWRzIjogeyJzb21lXyoiOiAzMn0sICJ1c2VycyI6IHsic29tZV8qIjogMzJ9LCAic3BhY2VzIjogeyJzb21lXyoiOiA3fX0sICJtZXRhIjoge30sICJ1dWlkIjogInNvbWVfdXVpZCJ9fZQu"
10+
},
11+
"headers": {
12+
"host": [
13+
"ps.pndsn.com"
14+
],
15+
"accept": [
16+
"*/*"
17+
],
18+
"accept-encoding": [
19+
"gzip, deflate"
20+
],
21+
"connection": [
22+
"keep-alive"
23+
],
24+
"user-agent": [
25+
"PubNub-Python/10.1.0"
26+
],
27+
"content-type": [
28+
"application/json"
29+
],
30+
"content-length": [
31+
"381"
32+
]
33+
}
34+
},
35+
"response": {
36+
"status": {
37+
"code": 200,
38+
"message": "OK"
39+
},
40+
"headers": {
41+
"Date": [
42+
"Tue, 11 Feb 2025 20:46:03 GMT"
43+
],
44+
"Content-Type": [
45+
"text/javascript; charset=UTF-8"
46+
],
47+
"Transfer-Encoding": [
48+
"chunked"
49+
],
50+
"Connection": [
51+
"keep-alive"
52+
],
53+
"cache-control": [
54+
"no-cache, no-store, must-revalidate"
55+
],
56+
"content-encoding": [
57+
"gzip"
58+
],
59+
"Access-Control-Allow-Credentials": [
60+
"true"
61+
],
62+
"Access-Control-Expose-Headers": [
63+
"*"
64+
]
65+
},
66+
"body": {
67+
"pickle": "gASVVwEAAAAAAAB9lIwGc3RyaW5nlEJEAQAAH4sIAAAAAAAA/2WRyW6DMBRFf6XyOgsGNS2RugglOE1UKkBgYBOZyaQMTmIDGZR/rwlIVdWl77PPebq+gRRzDBY3UGeMYZKBBXDbJBEHMAOcllkjkuPKVJalKcE6O/GeG+naYdA4G0ntXw+e842h2VKkXWNFrgLFoiF6biN0zjGywxfJapLmvYgDq4uRn0fqpksDfZiZtmr14dzsEkXjka89OHHts0CpSvilGWlgXSiqRq7qywMPrxw5RVX5PxeswK0cOPjnRdSMvi1JDeHsKYrG+xeqT9569L4edcmSE3X7+6YgxFkPXPdvBuUqhXCaOYdp78c+gnmIZEL63NppHtEVT2IfuudT7O6L1rR3utGsN6zOSmnZbu2wyNkbuM8Ay07dPhl6Xz5qf/rEjfiHk6ifccxbBhaKJN1/AJLBBPipAQAAlHMu"
68+
}
69+
}
70+
}
71+
]
72+
}

tests/integrational/fixtures/native_sync/pam/grant_token_with_uuid_and_channels.yaml

Lines changed: 0 additions & 46 deletions
This file was deleted.

tests/integrational/native_sync/test_grant_token.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,43 @@
22
from pubnub.pubnub import PubNub
33
from pubnub.models.consumer.v3.access_manager import PNGrantTokenResult
44
from pubnub.models.consumer.v3.channel import Channel
5+
from pubnub.models.consumer.v3.group import Group
6+
from pubnub.models.consumer.v3.uuid import UUID
57
from pubnub.models.consumer.v3.space import Space
6-
from tests.helper import pnconf_pam_copy
8+
from tests.helper import pnconf_pam_env_copy
79
from tests.integrational.vcr_helper import pn_vcr
810

9-
pubnub = PubNub(pnconf_pam_copy())
11+
pubnub = PubNub(pnconf_pam_env_copy())
1012
pubnub.config.uuid = "test_grant"
1113

1214

1315
@pn_vcr.use_cassette(
14-
'tests/integrational/fixtures/native_sync/pam/grant_token_with_uuid_and_channels.yaml',
16+
'tests/integrational/fixtures/native_sync/pam/grant_token_with_uuid_and_channels.json', serializer='pn_json',
1517
filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature']
1618
)
1719
def test_grant_auth_key_with_uuid_and_channels():
18-
envelope = pubnub.grant_token()\
19-
.ttl(60)\
20-
.authorized_uuid('some_uuid')\
20+
envelope = pubnub.grant_token() \
21+
.ttl(60) \
22+
.authorized_uuid('some_uuid') \
2123
.channels([
22-
Channel().id('some_channel_id').read().write(),
23-
Channel().pattern('some_*').read().write()
24-
])\
24+
Channel().id('some_channel_id').read().write().manage().delete().get().update().join(),
25+
Channel().pattern('some_*').read().write().manage()
26+
]) \
27+
.groups([
28+
Group().id('some_group_id').read().manage(),
29+
Group().pattern('some_*').read(),
30+
]) \
31+
.uuids([
32+
UUID().id('some_uuid').get().update().delete(),
33+
UUID().pattern('some_*').get()
34+
]) \
2535
.sync()
2636
assert isinstance(envelope.result, PNGrantTokenResult)
2737
assert envelope.result.token
2838

2939

3040
@pn_vcr.use_cassette(
31-
'tests/integrational/fixtures/native_sync/pam/grant_token_user_space.yaml',
41+
'tests/integrational/fixtures/native_sync/pam/grant_token_user_space.json', serializer='pn_json',
3242
filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'timestamp', 'signature']
3343
)
3444
def test_grant_auth_key_with_user_id_and_spaces():

0 commit comments

Comments
 (0)