Skip to content

Conversation

kleewho
Copy link
Contributor

@kleewho kleewho commented Oct 26, 2021

feat: Method grant_token has been added

grant_token allows generation of signed token with permissions for channels, channel groups and uuids

Added:

* grant_token method
* parse_token method
* cassettes for VCR tests
* contract tests
* contract tests integration with github actions

Co-authored with: Łukasz Klich ;)
@kleewho
Copy link
Contributor Author

kleewho commented Oct 26, 2021

@parfeon few questions:

  • Can we drop ruby 2.4.10? It's not maintained anymore since April 2020.
  • Event class treats channels and channel_groups specially but it's not how they should be handled in GrantToken. How do you think I should resolve that? Currently I'm just changing the name of the fields for internal usage in GrantToken and assign empty arrays to the special fields.
  • How to handle the cbor + jruby problem?

Copy link
Contributor

@parfeon parfeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PAMv3 looks good, but we need to be sure to keep compatibility with PAMv2

@event = current_operation
@uuid_perms = options[:uuids] || {}
@channel_perms = options[:channels] || {}
@channel_group_perms = options[:channel_groups] || {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kleewho it will be great to add new instance variables into create_variables_from_options method variables words list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, sure, I'll add it. Although I'm wondering what's the advantage? Could you elaborate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kleewho it is basically "built-in" in event automated variable assignment from passed list of options:

variables.each { |variable| instance_variable_set('@' + variable, options[variable.to_sym]) unless variable.nil? }

You can see, that instance_variable_set maps variables to values in options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeaaaaaah. How it will work with my name change though? I had to change it because event expect something else from channels than we have in grant_token

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kleewho I've totally forgot about formatter, which tries to pull out list of channels from array or string with comma-separated channel / groups names.

With this in mind it makes sense to clear those lists before super class will try to process them.
Other option can be use different names for arguments. Let user pass values under channel_perms - but not necessary.

@kleewho
Copy link
Contributor Author

kleewho commented Oct 27, 2021

FYI Plugging in acceptance tests is not yet finished

@kleewho kleewho requested a review from parfeon October 28, 2021 14:43
@kleewho
Copy link
Contributor Author

kleewho commented Oct 28, 2021

@parfeon I've run the acceptance tests against pubnub servers and against the mock. There's also better implementation of validation.

@kleewho kleewho requested a review from budgetpreneur November 8, 2021 10:12
Copy link

@budgetpreneur budgetpreneur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I will let @parfeon approve the PR, if his comments were addressed.

parfeon
parfeon previously approved these changes Nov 8, 2021
Copy link
Contributor

@parfeon parfeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good.

Just two places maybe require some attention :)

Comment on lines 38 to 49
- name: Expose main report
uses: actions/upload-artifact@v2
if: always()
with:
name: main.xml
path: main.xml
- name: Expose beta report
uses: actions/upload-artifact@v2
if: always()
with:
name: beta.xml
path: beta.xml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kleewho it will be better to upload two files as part of single artifact to reduce amount of customisations, which will be required for each repository to process reports.
Dart fo example upload both reports as acceptance-test-reports.

Maybe we can make it easier by modification of Combine test results task:

      - name: Combine test results
         if: always()
         run: |
           mkdir ./reports
           sudo npm install -g junit-report-merger &&
           jrm ./reports/main.xml "./main/**/*.xml" &&
           jrm ./reports/beta.xml "./beta/**/*.xml"

and then create single task to upload both reports:

      - name: Upload acceptance tests reports
          uses: actions/upload-artifact@v2
          if: always()
          with:
            name: acceptance-test-reports
            path: ./reports/*.xml
            retention-days: 7

With retention-days we also limit for how long reports will be stored. As soon as analyser will pull them out, there will be no use from the. With this configuration artifacts will be invalidated in 7 days.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Not a problem for me. I wasn't sure what's the expected way to do it

Comment on lines 161 to 191
if @read
sum |= 1
end

if @write
sum |= 2
end

if @manage
sum |= 4
end

if @delete
sum |= 8
end

if @create
sum |= 16
end

if @get
sum |= 32
end

if @update
sum |= 64
end

if @join
sum |= 128
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kleewho all these can be much smaller:

sum |= 1 if @read
sum |= 2 if @write
sum |= 4 if @manage
sum |= 8 if @delete
sum |= 16 if @create
sum |= 32 if @get
sum |= 64 if @update
sum |= 128 if @join

And pretty easy to read :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely better

parfeon
parfeon previously approved these changes Nov 9, 2021
Copy link
Contributor

@parfeon parfeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kleewho
Copy link
Contributor Author

kleewho commented Nov 9, 2021

@client-engineering-bot release

parfeon
parfeon previously approved these changes Nov 9, 2021
Copy link
Contributor

@parfeon parfeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Fix version format written with scripts by mistake (wrong settings in script).
@kleewho kleewho merged commit 734d938 into master Nov 9, 2021
@kleewho kleewho deleted the pamv3 branch November 9, 2021 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants