Skip to content
This repository has been archived by the owner. It is now read-only.

fix(tests): Update rate limit sms by ip address #191

Merged
merged 1 commit into from Mar 28, 2017

Conversation

@vbudhram
Copy link
Contributor

@vbudhram vbudhram commented Mar 27, 2017

This PR correctly rate limits when a user has sent more than 5 sms from an ip address. Previously, the the rate limiting was rate-limit when 5 unique sms requests sent from this ip address. Updated tests to be more reflective of this scenario.

Fixes #190

@rfk r?

@rfk
rfk approved these changes Mar 28, 2017
Copy link
Member

@rfk rfk left a comment

LGTM, r+ with nits

this.sms = this._trim(now, this.sms, limits.maxSms)
if (this.sms.length === 0) { return }
// xs is naturally ordered from oldest to newest
// and we only need to keep up to limits.maxEmails + 1

This comment has been minimized.

@rfk

rfk Mar 28, 2017
Member

comment nit: s/maxEmails/maxSms/

@@ -236,8 +234,8 @@ module.exports = function (limits, now) {
}

// Increment sms request count and throttle if needed
if (actions.isSmsSendingAction(action) && phoneNumber) {
this.addSmsRequest({ phoneNumber: phoneNumber })

This comment has been minimized.

@rfk

rfk Mar 28, 2017
Member

The phoneNumber argument appears to be unused after removing these, can we safely remote it or does it need to be kept for consistency with other records?

This comment has been minimized.

@vbudhram

vbudhram Mar 28, 2017
Author Contributor

Good catch, it can be removed.

@vbudhram vbudhram force-pushed the issue-190-fix-sms-rate-limit branch 2 times, most recently from dc7799b to 5f49655 Mar 28, 2017
@vbudhram vbudhram merged commit 2a70689 into master Mar 28, 2017
4 checks passed
4 checks passed
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.3%) to 95.598%
Details
@vbudhram vbudhram deleted the issue-190-fix-sms-rate-limit branch Mar 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants