Ejemplo n.º 1
0
 def test_validation_response(self, _mock):
     req = self.get_validation_request({"SecretKey": "SOME SECRET KEY", "Type": "Validation"})
     res = inbound_email(req)
     assert not _mock.called
     assert res.status_code == 200
     res.render()
     assert res.content == '"validation key"'
Ejemplo n.º 2
0
 def test_validation_response_wrong_secret(self, _mock):
     req = self.get_validation_request(
         {'SecretKey': 'WRONG SECRET', 'Type': 'Validation'}
     )
     res = inbound_email(req)
     assert not _mock.called
     assert res.status_code == 403
Ejemplo n.º 3
0
 def test_successful(self, _mock):
     req = self.get_request({"SecretKey": "SOME SECRET KEY", "Message": "something"})
     res = inbound_email(req)
     _mock.assert_called_with(("something",))
     assert res.status_code == 201
     res.render()
     assert res.content == '"validation key"'
Ejemplo n.º 4
0
 def test_validation_response(self, _mock):
     req = self.get_validation_request(
         {'SecretKey': 'SOME SECRET KEY', 'Type': 'Validation'})
     res = inbound_email(req)
     assert not _mock.called
     assert res.status_code == 200
     res.render()
     assert res.content == b'"validation key"'
Ejemplo n.º 5
0
 def test_successful(self, _mock):
     req = self.get_request(
         {'SecretKey': 'SOME SECRET KEY', 'Message': 'something'})
     res = inbound_email(req)
     _mock.assert_called_with(('something',))
     assert res.status_code == 201
     res.render()
     assert res.content == b'"validation key"'
Ejemplo n.º 6
0
    def test_basic(self):
        user = user_factory()
        self.grant_permission(user, "*:*")
        addon = addon_factory()
        version = addon.find_latest_version(channel=amo.RELEASE_CHANNEL_LISTED)
        req = self.get_request(sample_message_content)

        ActivityLogToken.objects.create(user=user, version=version, uuid="5a0b8a83d501412589cc5d562334b46b")

        res = inbound_email(req)
        assert res.status_code == 201
        res.render()
        assert res.content == '"validation key"'
        logs = ActivityLog.objects.for_addons(addon)
        assert logs.count() == 1
        assert logs.get(action=amo.LOG.REVIEWER_REPLY_VERSION.id)
Ejemplo n.º 7
0
    def test_basic(self):
        user = user_factory()
        self.grant_permission(user, '*:*')
        addon = addon_factory()
        req = self.get_request(sample_message_content)

        ActivityLogToken.objects.create(
            user=user,
            version=addon.latest_version,
            uuid='5a0b8a83d501412589cc5d562334b46b')

        res = inbound_email(req)
        assert res.status_code == 201
        logs = ActivityLog.objects.for_addons(addon)
        assert logs.count() == 1
        assert logs.get(action=amo.LOG.REVIEWER_REPLY_VERSION.id)
Ejemplo n.º 8
0
    def test_basic(self):
        user = user_factory()
        self.grant_permission(user, '*:*')
        addon = addon_factory()
        version = addon.find_latest_version(channel=amo.RELEASE_CHANNEL_LISTED)
        req = self.get_request(sample_message_content)

        ActivityLogToken.objects.create(
            user=user, version=version, uuid='5a0b8a83d501412589cc5d562334b46b'
        )

        res = inbound_email(req)
        assert res.status_code == 201
        res.render()
        assert res.content == b'"validation key"'
        logs = ActivityLog.objects.for_addons(addon)
        assert logs.count() == 1
        assert logs.get(action=amo.LOG.REVIEWER_REPLY_VERSION.id)
Ejemplo n.º 9
0
 def test_bad_request(self):
     """Test with no email body."""
     res = inbound_email(self.get_request({'SecretKey': 'SOME SECRET KEY'}))
     assert res.status_code == 400
Ejemplo n.º 10
0
 def test_validation_response_wrong_secret(self, _mock):
     req = self.get_validation_request(
         {'SecretKey': 'WRONG SECRET', 'Type': 'Validation'})
     res = inbound_email(req)
     assert not _mock.called
     assert res.status_code == 403
Ejemplo n.º 11
0
 def test_bad_request(self):
     """Test with no email body."""
     res = inbound_email(self.get_request({'SecretKey': 'SOME SECRET KEY'}))
     assert res.status_code == 400
Ejemplo n.º 12
0
 def test_validation_response_wrong_secret(self, _mock):
     req = self.get_validation_request({"SecretKey": "WRONG SECRET", "Type": "Validation"})
     res = inbound_email(req)
     assert not _mock.called
     assert res.status_code == 403