-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added rate-limiting facility #163
Conversation
152b4b8
to
51dbe48
Compare
Codecov Report
@@ Coverage Diff @@
## master #163 +/- ##
==========================================
+ Coverage 68.82% 69.36% +0.54%
==========================================
Files 31 32 +1
Lines 680 692 +12
==========================================
+ Hits 468 480 +12
Misses 212 212
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice that you created BDD scenario integration tests for new feature 👏🏻
I just need to understand (as commented) how it behaves.
I would also request the following change:
unit test rate-limiter.test.js
for rate-limiter.js
can be created (actually using TDD the test should be created before developing), for example:
I will also add TDD metodology examples, to illustrate the metodology applied to the current simple file.
- assert that
window
exists (TDD: test will break, so now you can create the first line of code inrate-limiter.js
:let window
, test passes...) - assert that
window
is aconst
(TDD: test will break, so now to pass you can justconst window = ''
, test passes) - assert that
window
has the same value fromdefault.js
,test.js
orproduction.js
(TDD: test break... test will pass when you rafactorconst window
to receiveconfig.get...
, test passes) - assert that
max
exists (TDD: test will break, so now you can createlet max
, test passes...) - assert that
max
is aconst
(TDD: test will break, so now to pass you can justconst max = ''
, test passes) - assert that
max
has the same value fromdefault.js
,test.js
orproduction.js
(TDD: test break... test will pass when you rafactorconst max
to receiveconfig.get...
) - assert that
rateLimit
exists (TDD: after this test we createrateLimit
(likelet rateLimit
) inrate-limiter.js
file, so test passes) - assert that
rateLimit
is strict equalrequire('express-rate-limit')
(TDD: test will break, causerateLimit
has not this value. So now we refactor existing rateLimit toconst rateLimit = require('express-rate-limit')
- test passes - assert that
rateLimiter
is equalrateLimit){...}
. (TDD: test will break, so you code= rateLimit({...}))
, test passes
I hope my comments are useful.
51dbe48
to
29669de
Compare
@christian-hawk my friend, Actually my first code was like
I covered test-cases about it in I pushed review changes, please review again and thank you for great review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done.
Now we just need to resolver the cucumber's 2 conversations and we are done!
Also please check if https://github.com/GluuFederation/gluu-passport/runs/1453194618 this codacy issue is a false-positive?
29669de
to
d2b320a
Compare
used express-rate-limit package, currently fetching configurations from production.js file feat #139
d2b320a
to
51b6ba3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still have an unresolved conversation from former review to dinamically tests endpoints behaviour.
@christian-hawk what you think now? #163 (comment) |
… 139_feat_rate_limiting
… 139_feat_rate_limiting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done made.
We just need to do the correct features
and steps
dynamically
I'm changing this to draft as it's still a work in progress. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice structure.
Please check priority comments on rate-limiting-steps.js
. I understand after that we are done.
adf0371
to
0005a8c
Compare
0005a8c
to
6210dca
Compare
…configuration file values As those are not blackbox tests, we should test against the static values from configuration file
here we can see that rate limiting counting is not being reset for each scenario example, I'm working on that. I also changed to static config values, you got a point here. After thinking I also understand that changing config file may go to our blackbox stage-testing instead of our whitebox functional tests (here). |
…heck So we can test against static responses (/token generates a token)
run tests |
As you requested, I did the changes for accurate tests. |
run tests |
1 similar comment
run tests |
3ef9db3
to
b9b103f
Compare
run tests |
@kdhttps 13:04:45 ============================================================================
13:04:45
13:04:45 - Provider type: IDP
13:04:45 - Type: passport-saml
13:04:45 - Flow: idp-initiated
13:04:45 - Passport Provider ID: saml-idpinit
13:04:45 TODO: Creating Trust Relation on t3.techno24x7.com automatically
13:04:45
13:04:45 - User data:
13:04:45 USER_NAME: hansdoe
13:04:45 USER_PASSWORD: test123
13:04:45 USER_MAIL: [email protected]
13:04:45 USER_GIVEN: hans
13:04:45 USER_SUR: doe
13:04:45
13:04:45 ----------------------------------------------------------------------------
13:04:45 RUNNING BLACKBOX BDT TESTS:
13:04:45 ----------------------------------------------------------------------------
13:04:45
13:04:45 Feature: accessing protected content # tests/behaver/features/protected-content.feature:1
13:04:50
13:04:50 Scenario: Not authenticated user access protected content # tests/behaver/features/protected-content.feature:3
13:04:50 Given that user exists in provider # tests/behaver/features/steps/protected-content.py:37
13:04:50 When user tries to access protected content page # tests/behaver/features/steps/protected-content.py:126
13:04:54 Then user should be redirected to login page # tests/behaver/features/steps/protected-content.py:140
13:05:08
13:05:08 Scenario: Authenticated user access protected content # tests/behaver/features/protected-content.feature:9
13:05:08 Given that user exists in provider # tests/behaver/features/steps/protected-content.py:37
13:05:08 And user is authenticated # tests/behaver/features/steps/protected-content.py:42
13:05:25 (None, None, None)
13:05:25 Traceback (most recent call last):
13:05:25 File "/var/lib/jenkins/.cache/pypoetry/virtualenvs/gluu-passport-testing-_NjlDPuR-py3.6/lib/python3.6/site-packages/behave/model.py", line 1329, in run
13:05:25 match.run(runner.context)
13:05:25 File "/var/lib/jenkins/.cache/pypoetry/virtualenvs/gluu-passport-testing-_NjlDPuR-py3.6/lib/python3.6/site-packages/behave/matchers.py", line 98, in run
13:05:25 self.func(context, *args, **kwargs)
13:05:25 File "tests/behaver/features/steps/protected-content.py", line 121, in user_authenticates
13:05:25 assert context.web.current_url.startswith(context.base_url)
13:05:25 AssertionError
13:05:25
13:05:26 When user tries to access protected content page # None
13:05:26 Then user should access protected content # None
13:05:26
13:05:26
13:05:26 Failing scenarios:
13:05:26 tests/behaver/features/protected-content.feature:9 Authenticated user access protected content
13:05:26
13:05:26 0 features passed, 1 failed, 0 skipped
13:05:26 1 scenario passed, 1 failed, 0 skipped
13:05:26 4 steps passed, 1 failed, 2 skipped, 0 undefined
13:05:26 Took 0m29.508s
13:05:26 entered teardown... Basically it says we are not getting in the desired URL at this point. |
Sure, I'll test it |
run tests |
1 similar comment
run tests |
Test are passing on my local machine. so we can merge this PR. @christian-hawk may I merge this PR??
|
Just a note: as jenkins automated tests are in alpha, when we find jenkins problem we run tests locally and merge. |
… 139_feat_rate_limiting
Used express-rate-limit package, currently fetching configurations from
production.js
filecloses #139