Skip to content
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

[xenial] fix Unknown status message: u'IMPORT_OK' related test failures #4038

Closed
redshiftzero opened this issue Jan 16, 2019 · 4 comments
Closed

Comments

@redshiftzero
Copy link
Contributor

Description

Unit tests involving importing an armored key/decryption appear to be failing, possibly related to #4013 (different error message though)

Steps to Reproduce

make test-xenial

Expected Behavior

All is merry and well

Actual Behavior

A bunch of integration test failures, e.g.:

_____________________________ test_submit_message ______________________________

source_app = <Flask 'source_app'>, journalist_app = <Flask 'journalist_app'>
test_journo = {'id': 1, 'journalist': <Journalist washboard confront imitation demise affidavit elf freewill radish>, 'otp_secret': 'YKZ3S3CWXEALHRTL', 'password': 'exclusion transpire emission fragrant confusion swept sappy yelp', ...}

    def test_submit_message(source_app, journalist_app, test_journo):
        """When a source creates an account, test that a new entry appears
        in the journalist interface"""
        test_msg = "This is a test message."
    
        with source_app.test_client() as app:
            app.get('/generate')
            app.post('/create', follow_redirects=True)
            filesystem_id = g.filesystem_id
            # redirected to submission form
            resp = app.post('/submit', data=dict(
                msg=test_msg,
                fh=(StringIO(''), ''),
            ), follow_redirects=True)
            assert resp.status_code == 200
            app.get('/logout')
    
        # Request the Journalist Interface index
        with journalist_app.test_client() as app:
            _login_user(app, test_journo)
            resp = app.get('/')
            assert resp.status_code == 200
            text = resp.data.decode('utf-8')
            assert "Sources" in text
            soup = BeautifulSoup(text, 'html.parser')
    
            # The source should have a "download unread" link that
            # says "1 unread"
            col = soup.select('ul#cols > li')[0]
            unread_span = col.select('span.unread a')[0]
            assert "1 unread" in unread_span.get_text()
    
            col_url = soup.select('ul#cols > li a')[0]['href']
            resp = app.get(col_url)
            assert resp.status_code == 200
            text = resp.data.decode('utf-8')
            soup = BeautifulSoup(text, 'html.parser')
            submission_url = soup.select('ul#submissions li a')[0]['href']
            assert "-msg" in submission_url
            span = soup.select('ul#submissions li span.info span')[0]
            assert re.compile('\d+ bytes').match(span['title'])
    
            resp = app.get(submission_url)
            assert resp.status_code == 200
            decrypted_data = journalist_app.crypto_util.gpg.decrypt(resp.data)
>           assert decrypted_data.ok
E           assert False
E            +  where False = <gnupg._parsers.Crypt object at 0x7f7dbf4d2f10>.ok

tests/test_integration.py:83: AssertionError
---------------------------- Captured stdout setup -----------------------------
seq  name             file                                                      
---  ---------------  ----------------------------------------------------------
0    main             /tmp/pytest-of-www-data/pytest-0/test_submit_message0/data
----------------------------- Captured stderr call -----------------------------
2019-01-16 04:31:25,916 INFO generating key, entropy: 8192
2019-01-16 04:31:26,230 INFO 'washboard confront imitation demise affidavit elf freewill radish' logged in with the token 619296
Exception in thread Thread-421:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/gnupg/_meta.py", line 650, in _read_response
    result._handle_status(keyword, value)
  File "/usr/local/lib/python2.7/dist-packages/gnupg/_parsers.py", line 995, in _handle_status
    raise ValueError("Unknown status message: %r" % key)
ValueError: Unknown status message: u'IMPORT_OK'

Exception in thread Thread-430:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/gnupg/_meta.py", line 650, in _read_response
    result._handle_status(keyword, value)
  File "/usr/local/lib/python2.7/dist-packages/gnupg/_parsers.py", line 1757, in _handle_status
    super(Crypt, self)._handle_status(key, value)
  File "/usr/local/lib/python2.7/dist-packages/gnupg/_parsers.py", line 1656, in _handle_status
    raise ValueError("Unknown status message: %r" % key)
ValueError: Unknown status message: u'IMPORT_OK'

Comments

I would bump to the latest python-gnupg and see if the issue was resolved upstream (I didn't see anything about this issue in the bugtracker, but worth a try), ref: #3622

@redshiftzero
Copy link
Contributor Author

heads up, see xenial-gpg, latest python-gnupg doesn't resolve

@kushaldas
Copy link
Contributor

If I remember correctly, these were due to the gpg version, gpg1 and gpg2.

@kushaldas
Copy link
Contributor

So @anweshadas provided the solution to fix these, I am running the tests right now. Will submit a PR for the fix.

@kushaldas
Copy link
Contributor

And all gpg related tests are passing. Now have to work for a reasonable patch from this.

kushaldas added a commit that referenced this issue Jan 17, 2019
For the python-gnupg to work properly on Xenial, we should
call `gpg` binary instead of `gpg2` (which we use in Trusty).
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

No branches or pull requests

2 participants