Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

feat: add ADM support #1290

Merged
merged 1 commit into from
Aug 30, 2018
Merged

feat: add ADM support #1290

merged 1 commit into from
Aug 30, 2018

Conversation

jrconlin
Copy link
Member

Closes #1275

@codecov-io
Copy link

codecov-io commented Aug 27, 2018

Codecov Report

Merging #1290 into master will decrease coverage by 0.01%.
The diff coverage is 99.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1290      +/-   ##
==========================================
- Coverage   99.95%   99.93%   -0.02%     
==========================================
  Files          59       60       +1     
  Lines        9573     9847     +274     
==========================================
+ Hits         9569     9841     +272     
- Misses          4        6       +2
Impacted Files Coverage Δ
autopush/web/webpush.py 100% <100%> (ø) ⬆️
autopush/router/__init__.py 100% <100%> (ø) ⬆️
autopush/tests/test_z_main.py 100% <100%> (ø) ⬆️
autopush/tests/test_integration.py 100% <100%> (ø) ⬆️
autopush/router/adm.py 100% <100%> (ø)
autopush/web/registration.py 100% <100%> (ø) ⬆️
autopush/main_argparse.py 100% <100%> (ø) ⬆️
autopush/config.py 99% <60%> (-1%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ffe5d96...0d84de6. Read the comment docs.

"crypto-key": [crypto_key],
"encryption": [salt],
"ttl": ["0"],
""
Copy link
Member

Choose a reason for hiding this comment

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

kill this stray line (it just str concats into "content-encoding")

Copy link
Member Author

Choose a reason for hiding this comment

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

Heh, had that in there for readability but then realized that i was the only person that cared.

headers = {
"content-type": "application/x-www-form-urlencoded"
}
resp = self._request.post(url, data=body, headers=headers)
Copy link
Member

Choose a reason for hiding this comment

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

we definitely want to specify some kind of timeout to requests calls, GCM bridge uses timeout=10. Then you have to catch the Timeout exception somewhere (probably _route)

Copy link
Member Author

Choose a reason for hiding this comment

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

agreed.

data["data"] = payload
url = ("https://api.amazon.com/messaging/registrations"
"/{}/messages".format(reg_id))
resp = self._request.post(
Copy link
Member

Choose a reason for hiding this comment

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

same timeout here

Copy link
Member

Choose a reason for hiding this comment

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

We can't use an async HTTP request? I know some of the router calls use third party tooling that we couldn't use the twisted http client with, but we should be able to here, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd prefer to do the async requests as a separate issue, since that will span multiple files and fuzz exactly what this patch is supposed to address.

self._mock_reply.text = "Test error"
self._mock_reply.content = "Test content"

# This will call RouterException, which may halt the test thread.
Copy link
Member

Choose a reason for hiding this comment

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

I don't get this comment, why would RouterException halt the test thread?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since we'd be calling via the _agent, RouterException is passed up and not trapped, causing _agent to fail out and kill/fail the test. I was not able to trap for it. Thus calling the send directly with the raise trap. I can try to muck about more with _agent to try and handle that sort of thing, but seems a bit out of scope for this patch.

Copy link
Member

Choose a reason for hiding this comment

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

That might be a case of twisted's TestCase failing if it sees a log.failure call made during the test. You can call self.flushLoggedErrors() at the end of tests to stop it from doing that

Copy link
Member Author

Choose a reason for hiding this comment

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

@pjenvey Ah, cool. I'll try that.

bbangert
bbangert previously approved these changes Aug 28, 2018
@bbangert bbangert merged commit 921a328 into master Aug 30, 2018
@bbangert bbangert deleted the feat/1275 branch August 30, 2018 18:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants