Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

Commit

Permalink
sprunge: Fix sprunge paste
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdaemon committed Jul 19, 2019
1 parent 830f20f commit aca1cba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/pastebins/sprunge.py
Expand Up @@ -17,11 +17,11 @@ def paste(self, data, ext):
encoded = data

params = {
'params': encoded
'sprunge': encoded,
}

try:
with requests.post(self.url, params=params) as response:
with requests.post(self.url, data=params) as response:
response.raise_for_status()
url = response.text.strip()
except HTTPError as e:
Expand Down
21 changes: 21 additions & 0 deletions tests/plugin_tests/test_paste_sprunge.py
Expand Up @@ -33,6 +33,27 @@ def test_paste(mock_requests):
assert paster.paste('test data', 'txt') == 'http://sprunge.us/foobar?txt'


def test_data_params(mock_requests):
importlib.reload(web)
importlib.reload(sprunge)

sprunge.register()

body = None

def req_cb(req):
nonlocal body
body = req.body
return 200, {}, 'http://sprunge.us/foobar\n'

paster = web.pastebins['sprunge']
mock_requests.add_callback(
'POST', 'http://sprunge.us', callback=req_cb
)
assert paster.paste('test data', 'txt') == 'http://sprunge.us/foobar?txt'
assert body == 'sprunge=test+data'


def test_paste_bytes(mock_requests):
importlib.reload(web)
importlib.reload(sprunge)
Expand Down

0 comments on commit aca1cba

Please sign in to comment.