pubnub 4.6.1 → 4.8.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pubnub might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +3 -1
- data/.github/workflows/commands-handler.yml +27 -0
- data/.github/workflows/release/versions.json +17 -0
- data/.github/workflows/release.yml +58 -0
- data/.github/workflows/run_acceptance_tests.yml +46 -0
- data/.gitignore +18 -0
- data/.pubnub.yml +32 -4
- data/.travis.yml +0 -4
- data/CHANGELOG.md +31 -6
- data/Gemfile +2 -0
- data/Gemfile.lock +42 -1
- data/VERSION +1 -1
- data/config/cucumber.yml +7 -0
- data/features/step_definitions/access_steps.rb +256 -0
- data/features/support/env.rb +15 -0
- data/features/support/helper.rb +39 -0
- data/features/support/hooks.rb +98 -0
- data/lib/pubnub/cbor.rb +182 -0
- data/lib/pubnub/client/events.rb +1 -1
- data/lib/pubnub/client/paged_history.rb +144 -17
- data/lib/pubnub/client.rb +14 -0
- data/lib/pubnub/constants.rb +10 -7
- data/lib/pubnub/event.rb +21 -10
- data/lib/pubnub/events/grant_token.rb +172 -0
- data/lib/pubnub/events/revoke_token.rb +66 -0
- data/lib/pubnub/validators/grant_token.rb +51 -0
- data/lib/pubnub/validators/revoke_token.rb +31 -0
- data/lib/pubnub/version.rb +1 -1
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f831ff43edccdc424ceea6408dae5d704d30c35fccb7e496d4e328a884169b6
|
4
|
+
data.tar.gz: c12621f317beac91d53b3008a5ba32a02557aff54e998f1b6e8ff3c27c2e88c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d575ef625dcdbc6fd15158740f557cc8914789de48ecfa6885e25c6d35ca86d7fa3bb09a1e85d871e5ae734e52ca8df5b96a85579be7bb784803d47dfb1d503
|
7
|
+
data.tar.gz: 2ec1515df9563f963bf3bfe664e8e4911a8737e72dbe44dde7d161008f11b3684d19e7c0e05bbd1dab6d2941fd8f442652bf16fe2fbe7b068b404a08bd7cc100
|
data/.github/CODEOWNERS
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Commands processor
|
2
|
+
|
3
|
+
on:
|
4
|
+
issue_comment:
|
5
|
+
types: [created]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
process:
|
9
|
+
name: Process command
|
10
|
+
if: ${{ github.event.issue.pull_request && endsWith(github.repository, '-private') != true && startsWith(github.event.comment.body, '@client-engineering-bot ') }}
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- name: Checkout repository
|
14
|
+
uses: actions/checkout@v2
|
15
|
+
- name: Checkout release actions
|
16
|
+
uses: actions/checkout@v2
|
17
|
+
with:
|
18
|
+
repository: pubnub/client-engineering-deployment-tools
|
19
|
+
ref: v1
|
20
|
+
token: ${{ secrets.GH_TOKEN }}
|
21
|
+
path: .github/.release/actions
|
22
|
+
- name: Process changelog entries
|
23
|
+
uses: ./.github/.release/actions/actions/commands
|
24
|
+
with:
|
25
|
+
token: ${{ secrets.GH_TOKEN }}
|
26
|
+
listener: client-engineering-bot
|
27
|
+
jira-api-key: ${{ secrets.JIRA_API_KEY }}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
".pubnub.yml": [
|
3
|
+
{ "pattern": "^version: \"(.+)\"$", "cleared": true },
|
4
|
+
{ "pattern": "\\s+package-name: pubnub-(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?).gem$", "cleared": true },
|
5
|
+
{ "pattern": "/releases/download/(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)/pubnub-.*.gem$", "cleared": false },
|
6
|
+
{ "pattern": "/releases/download/.*/pubnub-(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?).gem$", "cleared": true }
|
7
|
+
],
|
8
|
+
"VERSION": [
|
9
|
+
{ "pattern": "(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)", "cleared": true }
|
10
|
+
],
|
11
|
+
"Gemfile.lock": [
|
12
|
+
{ "pattern": "^\\s{2,}pubnub \\((v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)\\)$", "cleared": true }
|
13
|
+
],
|
14
|
+
"lib/pubnub/version.rb": [
|
15
|
+
{ "pattern": "^\\s{2,}VERSION = '(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)'.freeze", "cleared": true }
|
16
|
+
]
|
17
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
name: Automated product release
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches: [ master ]
|
6
|
+
types: [ closed ]
|
7
|
+
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
check-release:
|
11
|
+
name: Check release required
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
if: ${{ github.event.pull_request.merged && endsWith(github.repository, '-private') != true }}
|
14
|
+
outputs:
|
15
|
+
release: ${{ steps.check.outputs.ready }}
|
16
|
+
steps:
|
17
|
+
- name: Checkout actions
|
18
|
+
uses: actions/checkout@v2
|
19
|
+
with:
|
20
|
+
repository: pubnub/client-engineering-deployment-tools
|
21
|
+
ref: v1
|
22
|
+
token: ${{ secrets.GH_TOKEN }}
|
23
|
+
path: .github/.release/actions
|
24
|
+
- id: check
|
25
|
+
name: Check pre-release completed
|
26
|
+
uses: ./.github/.release/actions/actions/checks/release
|
27
|
+
with:
|
28
|
+
token: ${{ secrets.GH_TOKEN }}
|
29
|
+
publish:
|
30
|
+
name: Publish package
|
31
|
+
runs-on: ubuntu-latest
|
32
|
+
needs: check-release
|
33
|
+
if: ${{ needs.check-release.outputs.release == 'true' }}
|
34
|
+
steps:
|
35
|
+
- name: Checkout repository
|
36
|
+
uses: actions/checkout@v2
|
37
|
+
with:
|
38
|
+
# This should be the same as the one specified for on.pull_request.branches
|
39
|
+
ref: master
|
40
|
+
- name: Checkout actions
|
41
|
+
uses: actions/checkout@v2
|
42
|
+
with:
|
43
|
+
repository: pubnub/client-engineering-deployment-tools
|
44
|
+
ref: v1
|
45
|
+
token: ${{ secrets.GH_TOKEN }}
|
46
|
+
path: .github/.release/actions
|
47
|
+
- name: Publish to RubyGems
|
48
|
+
uses: ./.github/.release/actions/actions/services/rubygems
|
49
|
+
with:
|
50
|
+
token: ${{ secrets.GH_TOKEN }}
|
51
|
+
gem-username: ${{ secrets.GEMS_ACCOUNT }}
|
52
|
+
gem-token: ${{ secrets.GEMS_API_KEY }}
|
53
|
+
- name: Create Release
|
54
|
+
uses: ./.github/.release/actions/actions/services/github-release
|
55
|
+
with:
|
56
|
+
token: ${{ secrets.GH_TOKEN }}
|
57
|
+
jira-api-key: ${{ secrets.JIRA_API_KEY }}
|
58
|
+
last-service: true
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: run_acceptance_tests
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
name: Perform Acceptance BDD tests
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
steps:
|
10
|
+
- name: Checkout project
|
11
|
+
uses: actions/checkout@v2
|
12
|
+
- name: Checkout mock-server action
|
13
|
+
uses: actions/checkout@v2
|
14
|
+
with:
|
15
|
+
repository: pubnub/client-engineering-deployment-tools
|
16
|
+
ref: github-actions
|
17
|
+
token: ${{ secrets.GH_TOKEN }}
|
18
|
+
path: client-engineering-deployment-tools
|
19
|
+
- name: Run mock server action
|
20
|
+
uses: ./client-engineering-deployment-tools/actions/mock-server
|
21
|
+
with:
|
22
|
+
token: ${{ secrets.GH_TOKEN }}
|
23
|
+
- name: Install dependencies
|
24
|
+
run: |
|
25
|
+
sudo gem install bundler &&
|
26
|
+
bundle install
|
27
|
+
- name: Run acceptance tests (optional)
|
28
|
+
run: bundle exec cucumber sdk-specifications/features/ -p mock -p run_beta -p report_beta -f pretty
|
29
|
+
continue-on-error: true
|
30
|
+
- name: Run acceptance tests (required)
|
31
|
+
run: bundle exec cucumber sdk-specifications/features/ -p mock -p run_main -p report_main -f pretty
|
32
|
+
- name: Combine test results
|
33
|
+
if: always()
|
34
|
+
run: |
|
35
|
+
sudo npm install -g junit-report-merger &&
|
36
|
+
jrm ./main.xml "./main/**/*.xml" &&
|
37
|
+
jrm ./beta.xml "./beta/**/*.xml"
|
38
|
+
- name: Expose main report
|
39
|
+
uses: actions/upload-artifact@v2
|
40
|
+
if: always()
|
41
|
+
with:
|
42
|
+
name: acceptance-test-reports
|
43
|
+
path: |
|
44
|
+
main.xml
|
45
|
+
beta.xml
|
46
|
+
retention-days: 7
|
data/.gitignore
CHANGED
@@ -8,3 +8,21 @@ log/*
|
|
8
8
|
examples/test.rb
|
9
9
|
coverage
|
10
10
|
dev_scripts
|
11
|
+
|
12
|
+
# GitHub Actions #
|
13
|
+
##################
|
14
|
+
.github/.release
|
15
|
+
.bundle/ruby
|
16
|
+
|
17
|
+
.travis/README.md
|
18
|
+
.travis/scripts
|
19
|
+
|
20
|
+
deployment_keys
|
21
|
+
deployment_keys-private
|
22
|
+
deployment_keys.tar
|
23
|
+
|
24
|
+
.travis/github-labels-policy.json
|
25
|
+
.travis/github-labels.json
|
26
|
+
/.rvmrc
|
27
|
+
/.bundle/
|
28
|
+
/features/*.feature
|
data/.pubnub.yml
CHANGED
@@ -1,6 +1,30 @@
|
|
1
1
|
---
|
2
|
-
version: "4.
|
2
|
+
version: "4.8.0"
|
3
3
|
changelog:
|
4
|
+
- date: 2021-12-16
|
5
|
+
version: v4.8.0
|
6
|
+
changes:
|
7
|
+
- type: feature
|
8
|
+
text: "Add revoke token feature."
|
9
|
+
- date: 2021-11-24
|
10
|
+
version: v4.7.1
|
11
|
+
changes:
|
12
|
+
- type: feature
|
13
|
+
text: "Add new method `all_history_messages` which return messages from requested interval or `since` / `before` date in single object."
|
14
|
+
- type: bug
|
15
|
+
text: "Fix exception raised when optional start / end not passed to `paged_history`."
|
16
|
+
- date: 2021-11-09
|
17
|
+
version: v4.7.0
|
18
|
+
changes:
|
19
|
+
- type: feature
|
20
|
+
text: "Grant_token allows generation of signed token with permissions for channels, channel groups and uuids."
|
21
|
+
-
|
22
|
+
changes:
|
23
|
+
-
|
24
|
+
text: "Add new `sdks` section to `.pubnub.yml` with information about available artifacts and distribution variants."
|
25
|
+
type: improvement
|
26
|
+
date: 2021-06-09
|
27
|
+
version: v4.6.2
|
4
28
|
-
|
5
29
|
changes:
|
6
30
|
-
|
@@ -384,6 +408,10 @@ features:
|
|
384
408
|
access:
|
385
409
|
- ACCESS-GRANT
|
386
410
|
- ACCESS-SECRET-KEY-ALL-ACCESS
|
411
|
+
- ACCESS-GRANT-TOKEN
|
412
|
+
- ACCESS-PARSE-TOKEN
|
413
|
+
- ACCESS-SET-TOKEN
|
414
|
+
- ACCESS-REVOKE-TOKEN
|
387
415
|
channel-groups:
|
388
416
|
- CHANNEL-GROUPS-ADD-CHANNELS
|
389
417
|
- CHANNEL-GROUPS-REMOVE-CHANNELS
|
@@ -593,7 +621,7 @@ sdks:
|
|
593
621
|
- x86-64
|
594
622
|
- distribution-type: package
|
595
623
|
distribution-repository: RubyGems
|
596
|
-
package-name: pubnub-4.
|
624
|
+
package-name: pubnub-4.8.0.gem
|
597
625
|
location: https://rubygems.org/gems/pubnub
|
598
626
|
requires:
|
599
627
|
- name: addressable
|
@@ -698,8 +726,8 @@ sdks:
|
|
698
726
|
- x86-64
|
699
727
|
- distribution-type: library
|
700
728
|
distribution-repository: GitHub release
|
701
|
-
package-name: pubnub-4.
|
702
|
-
location: https://github.com/pubnub/ruby/releases/download/v4.
|
729
|
+
package-name: pubnub-4.8.0.gem
|
730
|
+
location: https://github.com/pubnub/ruby/releases/download/v4.8.0/pubnub-4.8.0.gem
|
703
731
|
requires:
|
704
732
|
- name: addressable
|
705
733
|
min-version: 2.0.0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
- Add
|
6
|
-
|
1
|
+
## v4.8.0
|
2
|
+
December 16 2021
|
3
|
+
|
4
|
+
#### Added
|
5
|
+
- Add revoke token feature.
|
6
|
+
|
7
|
+
## v4.7.1
|
8
|
+
November 24 2021
|
9
|
+
|
10
|
+
#### Added
|
11
|
+
- Add new method `all_history_messages` which return messages from requested interval or `since` / `before` date in single object.
|
12
|
+
|
13
|
+
#### Fixed
|
14
|
+
- Fix exception raised when optional start / end not passed to `paged_history`.
|
15
|
+
|
16
|
+
## v4.7.0
|
17
|
+
November 09 2021
|
18
|
+
|
19
|
+
#### Added
|
20
|
+
- Grant_token allows generation of signed token with permissions for channels, channel groups and uuids.
|
21
|
+
|
22
|
+
##### v4.6.2
|
23
|
+
|
24
|
+
- Add new `sdks` section to `.pubnub.yml` with information about available artifacts and distribution variants.
|
25
|
+
|
26
|
+
##### v4.6.1
|
27
|
+
|
28
|
+
- Exclude `spec` and `fixtures` from built gem file.
|
29
|
+
- Fix Ruby SDK repository location under `sdks` section in `.pubnub.yml`.
|
30
|
+
- Add new section to `.pubnub.yml` file with information about SDK and destribution types.
|
31
|
+
|
7
32
|
##### v4.6.0
|
8
33
|
|
9
34
|
- BREAKING CHANGE: Add randomized initialization vector usage by default for data encryption / decryption in publish / subscribe / history API calls.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pubnub (4.
|
4
|
+
pubnub (4.8.0)
|
5
5
|
addressable (>= 2.0.0)
|
6
6
|
concurrent-ruby (~> 1.1.5)
|
7
7
|
concurrent-ruby-edge (~> 0.5.0)
|
@@ -19,6 +19,7 @@ GEM
|
|
19
19
|
awesome_print (1.8.0)
|
20
20
|
binding_of_caller (0.8.0)
|
21
21
|
debug_inspector (>= 0.0.1)
|
22
|
+
builder (3.2.4)
|
22
23
|
codacy-coverage (2.2.1)
|
23
24
|
simplecov
|
24
25
|
coderay (1.1.3)
|
@@ -27,6 +28,37 @@ GEM
|
|
27
28
|
concurrent-ruby (~> 1.1.5)
|
28
29
|
crack (0.4.3)
|
29
30
|
safe_yaml (~> 1.0.0)
|
31
|
+
cucumber (7.0.0)
|
32
|
+
builder (~> 3.2, >= 3.2.4)
|
33
|
+
cucumber-core (~> 10.0, >= 10.0.1)
|
34
|
+
cucumber-create-meta (~> 6.0, >= 6.0.1)
|
35
|
+
cucumber-cucumber-expressions (~> 12.1, >= 12.1.1)
|
36
|
+
cucumber-gherkin (~> 20.0, >= 20.0.1)
|
37
|
+
cucumber-html-formatter (~> 16.0, >= 16.0.1)
|
38
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
39
|
+
cucumber-wire (~> 6.0, >= 6.0.1)
|
40
|
+
diff-lcs (~> 1.4, >= 1.4.4)
|
41
|
+
mime-types (~> 3.3, >= 3.3.1)
|
42
|
+
multi_test (~> 0.1, >= 0.1.2)
|
43
|
+
sys-uname (~> 1.2, >= 1.2.2)
|
44
|
+
cucumber-core (10.0.1)
|
45
|
+
cucumber-gherkin (~> 20.0, >= 20.0.1)
|
46
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
47
|
+
cucumber-tag-expressions (~> 3.0, >= 3.0.1)
|
48
|
+
cucumber-create-meta (6.0.1)
|
49
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
50
|
+
sys-uname (~> 1.2, >= 1.2.2)
|
51
|
+
cucumber-cucumber-expressions (12.1.3)
|
52
|
+
cucumber-gherkin (20.0.1)
|
53
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
54
|
+
cucumber-html-formatter (16.0.1)
|
55
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
56
|
+
cucumber-messages (17.1.1)
|
57
|
+
cucumber-tag-expressions (3.0.1)
|
58
|
+
cucumber-wire (6.1.1)
|
59
|
+
cucumber-core (~> 10.0, >= 10.0.1)
|
60
|
+
cucumber-cucumber-expressions (~> 12.1, >= 12.1.2)
|
61
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
30
62
|
debug_inspector (0.0.3)
|
31
63
|
diff-lcs (1.4.4)
|
32
64
|
docile (1.3.2)
|
@@ -68,6 +100,7 @@ GEM
|
|
68
100
|
dry-equalizer (~> 0.2)
|
69
101
|
dry-initializer (~> 3.0)
|
70
102
|
dry-schema (~> 1.5)
|
103
|
+
ffi (1.13.1)
|
71
104
|
ffi (1.13.1-java)
|
72
105
|
hashdiff (1.0.1)
|
73
106
|
httpclient (2.8.3)
|
@@ -75,6 +108,10 @@ GEM
|
|
75
108
|
json (2.3.1)
|
76
109
|
json (2.3.1-java)
|
77
110
|
method_source (1.0.0)
|
111
|
+
mime-types (3.3.1)
|
112
|
+
mime-types-data (~> 3.2015)
|
113
|
+
mime-types-data (3.2021.0901)
|
114
|
+
multi_test (0.1.2)
|
78
115
|
parallel (1.19.2)
|
79
116
|
parser (2.7.1.4)
|
80
117
|
ast (~> 2.4.1)
|
@@ -130,6 +167,8 @@ GEM
|
|
130
167
|
simplecov-html (0.12.2)
|
131
168
|
spoon (0.0.6)
|
132
169
|
ffi
|
170
|
+
sys-uname (1.2.2)
|
171
|
+
ffi (~> 1.1)
|
133
172
|
timers (4.3.0)
|
134
173
|
unicode-display_width (1.7.0)
|
135
174
|
vcr (6.0.0)
|
@@ -145,12 +184,14 @@ PLATFORMS
|
|
145
184
|
DEPENDENCIES
|
146
185
|
awesome_print
|
147
186
|
codacy-coverage
|
187
|
+
cucumber
|
148
188
|
pry
|
149
189
|
pry-rescue
|
150
190
|
pry-stack_explorer
|
151
191
|
pubnub!
|
152
192
|
rr
|
153
193
|
rspec
|
194
|
+
rspec-expectations
|
154
195
|
rspec-retry
|
155
196
|
rubocop
|
156
197
|
simplecov (>= 0.12)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.
|
1
|
+
4.8.0
|
data/config/cucumber.yml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
default: -p mock -p run_main
|
2
|
+
run_main: -t "not @skip and not @na=ruby and not @beta"
|
3
|
+
report_main: -f junit --out main
|
4
|
+
run_beta: -t "not @skip and not @na=ruby and @beta"
|
5
|
+
report_beta: -f junit --out beta
|
6
|
+
mock: SERVER_MOCK=true PAM_SUB_KEY=subKey PAM_PUB_KEY=pubKey PAM_SEC_KEY=secKey SERVER_HOST=localhost SERVER_PORT=8090
|
7
|
+
prod: SERVER_MOCK=false
|
@@ -0,0 +1,256 @@
|
|
1
|
+
require 'pubnub'
|
2
|
+
|
3
|
+
token_with_all = "qEF2AkF0GmEI03xDdHRsGDxDcmVzpURjaGFuoWljaGFubmVsLTEY70NncnChb2NoYW5uZWxfZ3JvdXAtMQVDdXNyoENzcGOgRHV1aWShZnV1aWQtMRhoQ3BhdKVEY2hhbqFtXmNoYW5uZWwtXFMqJBjvQ2dycKF0XjpjaGFubmVsX2dyb3VwLVxTKiQFQ3VzcqBDc3BjoER1dWlkoWpedXVpZC1cUyokGGhEbWV0YaBEdXVpZHR0ZXN0LWF1dGhvcml6ZWQtdXVpZENzaWdYIPpU-vCe9rkpYs87YUrFNWkyNq8CVvmKwEjVinnDrJJc"
|
4
|
+
|
5
|
+
Given('I have a keyset with access manager enabled') do
|
6
|
+
expect(ENV['PAM_SUB_KEY']).not_to be_nil
|
7
|
+
expect(ENV['PAM_PUB_KEY']).not_to be_nil
|
8
|
+
expect(ENV['PAM_SEC_KEY']).not_to be_nil
|
9
|
+
@pn_configuration['subscribe_key'] = ENV['PAM_SUB_KEY']
|
10
|
+
@pn_configuration['publish_key'] = ENV['PAM_PUB_KEY']
|
11
|
+
@pn_configuration['secret_key'] = ENV['PAM_SEC_KEY']
|
12
|
+
logger = Logger.new(STDOUT)
|
13
|
+
logger.level = Logger::DEBUG
|
14
|
+
@pn_configuration['logger'] = logger
|
15
|
+
|
16
|
+
@pubnub = Pubnub.new(@pn_configuration)
|
17
|
+
end
|
18
|
+
|
19
|
+
Given('I have a keyset with access manager enabled - without secret key') do
|
20
|
+
expect(ENV['PAM_SUB_KEY']).not_to be_nil
|
21
|
+
expect(ENV['PAM_PUB_KEY']).not_to be_nil
|
22
|
+
@pn_configuration['subscribe_key'] = ENV['PAM_SUB_KEY']
|
23
|
+
@pn_configuration['publish_key'] = ENV['PAM_PUB_KEY']
|
24
|
+
logger = Logger.new(STDOUT)
|
25
|
+
logger.level = Logger::DEBUG
|
26
|
+
@pn_configuration['logger'] = logger
|
27
|
+
|
28
|
+
@pubnub = Pubnub.new(@pn_configuration)
|
29
|
+
end
|
30
|
+
|
31
|
+
Given('the authorized UUID {string}') do |uuid|
|
32
|
+
@grant_token_state[:authorized_uuid] = uuid
|
33
|
+
end
|
34
|
+
|
35
|
+
Given('the TTL {int}') do |ttl|
|
36
|
+
@grant_token_state[:ttl] = ttl
|
37
|
+
end
|
38
|
+
|
39
|
+
Given('the {string} {resourceType} resource access permissions') do |name, resource_type|
|
40
|
+
@grant_token_state[:current_name] = name
|
41
|
+
|
42
|
+
@grant_token_state[:current_grant][name] = {
|
43
|
+
:name => name,
|
44
|
+
:resource_type => resource_type,
|
45
|
+
:permission_type => []
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
And('grant resource permission {permissionType}') do |permission_type|
|
50
|
+
current_name = @grant_token_state[:current_name]
|
51
|
+
@grant_token_state[:current_grant][current_name][:permission_type].push(permission_type)
|
52
|
+
end
|
53
|
+
|
54
|
+
Given('the {string} {resourceType} pattern access permissions') do |pattern, resource_type|
|
55
|
+
@grant_token_state[:current_pattern] = pattern
|
56
|
+
@grant_token_state[:current_grant][pattern] = {
|
57
|
+
:pattern => pattern,
|
58
|
+
:resource_type => resource_type,
|
59
|
+
:permission_type => []
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
Given('a valid token with permissions to publish with channel {string}') do |string|
|
64
|
+
@grant_token_state[:token] = token_with_all
|
65
|
+
end
|
66
|
+
|
67
|
+
Given('a token') do
|
68
|
+
@grant_token_state[:token] = token_with_all
|
69
|
+
end
|
70
|
+
|
71
|
+
Given('an expired token with permissions to publish with channel {string}') do |string|
|
72
|
+
@grant_token_state[:token] = token_with_all
|
73
|
+
end
|
74
|
+
|
75
|
+
And('grant pattern permission {permissionType}') do |permission_type|
|
76
|
+
current_pattern = @grant_token_state[:current_pattern]
|
77
|
+
@grant_token_state[:current_grant][current_pattern][:permission_type].push(permission_type)
|
78
|
+
end
|
79
|
+
|
80
|
+
When('I grant a token specifying those permissions') do
|
81
|
+
res = call_grant_token(@pubnub, @grant_token_state)
|
82
|
+
@grant_token_state[:parsed_token] = @pubnub.parse_token(res.result[:data]["token"])
|
83
|
+
end
|
84
|
+
|
85
|
+
When('I publish a message using that auth token with channel {string}') do |channel|
|
86
|
+
@pubnub.set_token(@grant_token_state[:token])
|
87
|
+
res = @pubnub.publish(
|
88
|
+
message: "This is message",
|
89
|
+
channel: channel,
|
90
|
+
http_sync: true
|
91
|
+
)
|
92
|
+
@global_state[:last_call_res] = res
|
93
|
+
end
|
94
|
+
|
95
|
+
When('I attempt to publish a message using that auth token with channel {string}') do |channel|
|
96
|
+
@pubnub.set_token(@grant_token_state[:token])
|
97
|
+
res = @pubnub.publish(
|
98
|
+
message: "This is message",
|
99
|
+
channel: channel,
|
100
|
+
http_sync: true
|
101
|
+
)
|
102
|
+
@global_state[:last_call_res] = res
|
103
|
+
end
|
104
|
+
|
105
|
+
When('I revoke a token') do
|
106
|
+
res = @pubnub.revoke_token(
|
107
|
+
token: @grant_token_state[:token],
|
108
|
+
http_sync: true
|
109
|
+
)
|
110
|
+
@global_state[:last_call_res] = res
|
111
|
+
end
|
112
|
+
|
113
|
+
Then('the token contains the authorized UUID {string}') do |expected_uuid|
|
114
|
+
expect(@grant_token_state[:parsed_token]["uuid"]).to eq expected_uuid
|
115
|
+
end
|
116
|
+
|
117
|
+
Then('the token contains the TTL {int}') do |ttl|
|
118
|
+
expect(@grant_token_state[:parsed_token]["ttl"]).to eq ttl
|
119
|
+
end
|
120
|
+
|
121
|
+
Then('the token has {string} {resourceType} resource access permissions') do |resource, resource_type|
|
122
|
+
case resource_type
|
123
|
+
when "CHANNEL"
|
124
|
+
@grant_token_state[:token_resource] = @grant_token_state[:parsed_token]["res"]["chan"][resource]
|
125
|
+
when "CHANNEL_GROUP"
|
126
|
+
@grant_token_state[:token_resource] = @grant_token_state[:parsed_token]["res"]["grp"][resource]
|
127
|
+
when "UUID"
|
128
|
+
@grant_token_state[:token_resource] = @grant_token_state[:parsed_token]["res"]["uuid"][resource]
|
129
|
+
else
|
130
|
+
fail
|
131
|
+
end
|
132
|
+
|
133
|
+
expect(@grant_token_state[:token_resource]).not_to eq nil
|
134
|
+
end
|
135
|
+
|
136
|
+
Then('token resource permission {permissionType}') do |permission_type|
|
137
|
+
expect(has_permission(@grant_token_state[:token_resource], permission_type)).to eq true
|
138
|
+
end
|
139
|
+
|
140
|
+
Then('the token has {string} {resourceType} pattern access permissions') do |pattern, resourceType|
|
141
|
+
case resourceType
|
142
|
+
when "CHANNEL"
|
143
|
+
@grant_token_state[:token_resource] = @grant_token_state[:parsed_token]["pat"]["chan"][pattern]
|
144
|
+
when "CHANNEL_GROUP"
|
145
|
+
@grant_token_state[:token_resource] = @grant_token_state[:parsed_token]["pat"]["grp"][pattern]
|
146
|
+
when "UUID"
|
147
|
+
@grant_token_state[:token_resource] = @grant_token_state[:parsed_token]["pat"]["uuid"][pattern]
|
148
|
+
else
|
149
|
+
fail
|
150
|
+
end
|
151
|
+
|
152
|
+
expect(@grant_token_state[:token_resource]).not_to eq nil
|
153
|
+
end
|
154
|
+
|
155
|
+
And('token pattern permission {permissionType}') do |permission_type|
|
156
|
+
expect(has_permission(@grant_token_state[:token_resource], permission_type)).to eq true
|
157
|
+
end
|
158
|
+
|
159
|
+
Then('the token does not contain an authorized uuid') do
|
160
|
+
expect(@grant_token_state[:parsed_token]["uuid"]).to eq nil
|
161
|
+
end
|
162
|
+
|
163
|
+
Given('deny resource permission {permissionType}') do |permission_type|
|
164
|
+
current_name = @grant_token_state[:current_name]
|
165
|
+
@grant_token_state[:current_grant][current_name][:permission_type].filter { |p| p != permission_type }
|
166
|
+
end
|
167
|
+
|
168
|
+
When('I attempt to grant a token specifying those permissions') do
|
169
|
+
@global_state[:last_call_res] = call_grant_token(@pubnub, @grant_token_state)
|
170
|
+
end
|
171
|
+
|
172
|
+
Then('an error is returned') do
|
173
|
+
envelope = @global_state[:last_call_res]
|
174
|
+
expect(envelope).not_to eq nil
|
175
|
+
expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
|
176
|
+
end
|
177
|
+
|
178
|
+
Then('the error status code is {int}') do |code|
|
179
|
+
expect(@global_state[:last_call_res].status[:code]).to eq code
|
180
|
+
end
|
181
|
+
|
182
|
+
Then('the error message is {string}') do |error_message|
|
183
|
+
expect(parse_error_body(@global_state[:last_call_res])["error"]["message"]).to eq error_message
|
184
|
+
end
|
185
|
+
|
186
|
+
Then('the error source is {string}') do |error_source|
|
187
|
+
expect(parse_error_body(@global_state[:last_call_res])["error"]["source"]).to eq error_source
|
188
|
+
end
|
189
|
+
|
190
|
+
Then('the error detail message is {string}') do |details_message|
|
191
|
+
expect(parse_error_body(@global_state[:last_call_res])["error"]["details"][0]["message"]).to eq details_message
|
192
|
+
end
|
193
|
+
|
194
|
+
Then('the error detail location is {string}') do |details_location|
|
195
|
+
expect(parse_error_body(@global_state[:last_call_res])["error"]["details"][0]["location"]).to eq details_location
|
196
|
+
end
|
197
|
+
|
198
|
+
Then('the error detail location type is {string}') do |location_type|
|
199
|
+
expect(parse_error_body(@global_state[:last_call_res])["error"]["details"][0]["locationType"]).to eq location_type
|
200
|
+
end
|
201
|
+
|
202
|
+
Given('I have a known token containing an authorized UUID') do
|
203
|
+
@grant_token_state[:token] = token_with_all
|
204
|
+
end
|
205
|
+
|
206
|
+
When('I parse the token') do
|
207
|
+
@grant_token_state[:parsed_token] = @pubnub.parse_token(@grant_token_state[:token])
|
208
|
+
end
|
209
|
+
|
210
|
+
Then('the parsed token output contains the authorized UUID {string}') do |expected_uuid|
|
211
|
+
expect(@grant_token_state[:parsed_token]["uuid"]).to eq expected_uuid
|
212
|
+
end
|
213
|
+
|
214
|
+
Given('I have a known token containing UUID resource permissions') do
|
215
|
+
@grant_token_state[:token] = token_with_all
|
216
|
+
end
|
217
|
+
|
218
|
+
Given('I have a known token containing UUID pattern Permissions') do
|
219
|
+
@grant_token_state[:token] = token_with_all
|
220
|
+
end
|
221
|
+
|
222
|
+
Given('the token string {string}') do |token|
|
223
|
+
@grant_token_state[:token] = token
|
224
|
+
end
|
225
|
+
|
226
|
+
Then('the result is successful') do
|
227
|
+
envelope = @global_state[:last_call_res]
|
228
|
+
expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq false
|
229
|
+
expect(envelope.status[:code]).to eq 200
|
230
|
+
end
|
231
|
+
|
232
|
+
Then('an auth error is returned') do
|
233
|
+
envelope = @global_state[:last_call_res]
|
234
|
+
expect(envelope).not_to eq nil
|
235
|
+
expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
|
236
|
+
end
|
237
|
+
|
238
|
+
Then('the auth error message is {string}') do |error_message|
|
239
|
+
expect(parse_error_body(@global_state[:last_call_res])["message"]).to eq error_message
|
240
|
+
end
|
241
|
+
|
242
|
+
Then('the error service is {string}') do |service|
|
243
|
+
expect(parse_error_body(@global_state[:last_call_res])["service"]).to eq service
|
244
|
+
end
|
245
|
+
|
246
|
+
Then('I get confirmation that token has been revoked') do
|
247
|
+
envelope = @global_state[:last_call_res]
|
248
|
+
expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq false
|
249
|
+
expect(envelope.status[:code]).to eq 200
|
250
|
+
end
|
251
|
+
|
252
|
+
Then('the error detail message is not empty') do
|
253
|
+
expect(parse_error_body(@global_state[:last_call_res])["error"]["message"].empty?).to eq false
|
254
|
+
end
|
255
|
+
|
256
|
+
|