Exemplo n.º 1
0
    def test_products(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server,
                '/products/versions/Firefox:9.0a1/',
            )
            self.assertEqual(response.data, {'hits': [], 'total': 0})
Exemplo n.º 2
0
    def test_products_builds(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server,
                '/products/builds/product/Firefox/version/9.0a1/',
            )
            self.assertEqual(response.data, [])
Exemplo n.º 3
0
    def test_priorityjobs(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(server, '/priorityjobs/uuid/%s/' % self.uuid)
            self.assertEqual(response.data, {'hits': [], 'total': 0})

            response = self.post(server, '/priorityjobs/uuid/%s/' % self.uuid)
            self.assertEqual(response.data, {'hits': [], 'total': 0})
Exemplo n.º 4
0
    def test_crashtrends(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server,
                '/crashtrends/start_date/2012-03-01/end_date/2012-03-15/'
                'product/Firefox/version/13.0a1')
            self.assertEqual(response.data, {'crashtrends': []})
Exemplo n.º 5
0
    def test_post_bad_product(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.post(server, '/products/', {
                'product': 'Spaces not allowed',
                'version': '',
            })
            eq_(response.data, False)
Exemplo n.º 6
0
    def test_signatureurls(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server, '/signatureurls/signature/samplesignature/start_date/'
                '2012-03-01T00:00:00+00:00/end_date/2012-03-31T00:00:00+00:00/'
                'products/Firefox+Fennec/versions/Firefox:4.0.1+Fennec:13.0/')
            self.assertEqual(response.data, {'hits': [], 'total': 0})
Exemplo n.º 7
0
    def test_releases(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server,
                '/releases/featured/products/Firefox+Fennec/',
            )
            self.assertEqual(response.data, {'hits': {}, 'total': 0})
Exemplo n.º 8
0
    def test_report_list(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server,
                '/report/list/signature/SocketSend/'
                'from/2011-05-01/to/2011-05-05/'
            )
            self.assertEqual(response.data, {'hits': [], 'total': 0})
Exemplo n.º 9
0
    def test_util_versions_info(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server,
                '/util/versions_info/',
                {'versions': ['Firefox:9.0a1', 'Fennec:7.0']}
            )
            eq_(response.data, {})
Exemplo n.º 10
0
    def test_releases_featured(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server,
                '/releases/featured/',
                {'products': ['Firefox', 'Fennec']}
            )
            eq_(response.data, {'hits': {}, 'total': 0})
Exemplo n.º 11
0
    def test_crashes(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server,
                '/crashes/comments/',
                {'signature': 'xxx', 'from': '2011-05-01'}
            )
            eq_(response.data, {'hits': [], 'total': 0})

            response = self.get(
                server,
                '/crashes/daily/',
                {
                    'product': 'Firefox',
                    'versions': ['9.0a1', '16.0a1'],
                    'from': '2011-05-01',
                    'to': '2011-05-05',
                }
            )
            eq_(response.data, {'hits': {}})

            response = self.get(
                server,
                '/crashes/frequency/',
                {
                    'signature': 'SocketSend',
                    'from_date': '2011-05-01',
                    'to_date': '2011-05-05',
                }
            )
            eq_(response.data, {'hits': [], 'total': 0})

            response = self.get(
                server,
                '/crashes/signatures/',
                {'product': 'Firefox', 'version': '9.0a1'}
            )
            eq_(response.data['crashes'], [])

            response = self.get(
                server,
                '/crashes/exploitability/'
            )
            eq_(response.data, {'hits': [], 'total': 0})
Exemplo n.º 12
0
    def test_field(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(server, '/field/', {'name': 'something'})
            eq_(response.data, {
                'name': None,
                'transforms': None,
                'product': None
            })
Exemplo n.º 13
0
    def test_releases_featured_put(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.put(
                server,
                '/releases/featured/',
                {'Firefox': '15.0a1,14.0b1'},
            )
            eq_(response.data, False)
Exemplo n.º 14
0
    def test_laglog(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server,
                '/laglog/',
            )
            eq_(response.status, 200)
            eq_(json.loads(response.body), {'replicas': []})
Exemplo n.º 15
0
    def test_search(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server,
                '/search/crashes/for/libflash.so/in/signature/products/'
                'Firefox/versions/Firefox:4.0.1/from/2011-05-01/to/'
                '2011-05-05/os/Windows/')
            self.assertEqual(response.data, {'hits': [], 'total': 0})
Exemplo n.º 16
0
    def test_bugs(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.post(server, '/bugs/',
                                 {'signatures': ['sign1', 'sign2']})
            eq_(response.data, {'hits': [], u'total': 0})

            # because the bugs API is using POST and potentially multiple
            # signatures, it's a good idea to write a full integration test

            cursor = self.conn.cursor()
            cursor.execute(
                """
            INSERT INTO bugs VALUES
            (1),
            (2),
            (3);
            INSERT INTO bug_associations
            (signature, bug_id)
            VALUES
            (%s, 1),
            (%s, 3),
            (%s, 2);
            """, ('othersig', 'si/gn1', 'sign2+'))
            self.conn.commit()

            response = self.post(server, '/bugs/',
                                 {'signatures': ['si/gn1', 'sign2+']})
            hits = sorted(response.data['hits'], key=lambda k: k['id'])
            eq_(response.data['total'], 2)
            eq_(hits, [{
                u'id': 2,
                u'signature': u'sign2+'
            }, {
                u'id': 3,
                u'signature': u'si/gn1'
            }])

            response = self.post(server, '/bugs/', {'signatures': 'othersig'})
            eq_(response.data['total'], 1)
            eq_(response.data['hits'], [{u'id': 1, u'signature': u'othersig'}])

            response = self.post(server, '/bugs/',
                                 {'signatures': ['never', 'heard', 'of']})
            eq_(response.data, {'hits': [], u'total': 0})
Exemplo n.º 17
0
    def test_signaturesummary(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server, '/signaturesummary/report_type/products/'
                'signature/sig%2Bnature'
                '/start_date/2012-02-29T01:23:45+00:00/end_date/'
                '2012-02-29T01:23:45+00:00/versions/1+2')
            self.assertEqual(response.data, [])
Exemplo n.º 18
0
    def test_missing_argument_yield_bad_request(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(server,
                                '/crashes/comments/',
                                expect_errors=True)
            eq_(response.status, 400)
            ok_('signature' in response.body)

            response = self.get(server, '/crashes/daily/', expect_errors=True)
            eq_(response.status, 400)
            ok_('product' in response.body)

            response = self.get(server,
                                '/crashes/daily/', {'product': 'Firefox'},
                                expect_errors=True)
            eq_(response.status, 400)
            ok_('versions' in response.body)

            response = self.get(server, '/priorityjobs/', expect_errors=True)
            eq_(response.status, 500)

            response = self.post(server, '/priorityjobs/', expect_errors=True)
            eq_(response.status, 400)

            response = self.post(
                server,
                '/priorityjobs/',
                {'uuid': 1234689},
            )
            eq_(response.status, 200)

            response = self.get(
                server,
                '/signatureurls/', {
                    'signXXXXe': 'samplesignature',
                    'start_date': '2012-03-01T00:00:00+00:00',
                    'end_date': '2012-03-31T00:00:00+00:00',
                    'products': ['Firefox', 'Fennec'],
                    'versions': ['Firefox:4.0.1', 'Fennec:13.0'],
                },
                expect_errors=True)
            eq_(response.status, 400)
            ok_('signature' in response.body)
Exemplo n.º 19
0
    def test_report_list(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server, '/report/list/', {
                    'signature': 'SocketSend',
                    'from': '2011-05-01',
                    'to': '2011-05-05',
                })
            eq_(response.data, {'hits': [], 'total': 0})
Exemplo n.º 20
0
    def test_priorityjobs(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(server,
                                '/priorityjobs/', {'uuid': self.uuid},
                                expect_errors=True)
            eq_(response.status, 500)

            response = self.post(server, '/priorityjobs/', {'uuid': self.uuid})
            ok_(response.data)
Exemplo n.º 21
0
    def test_crashtrends(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server, '/crashtrends/', {
                    'start_date': '2012-03-01',
                    'end_date': '2012-03-15',
                    'product': 'Firefox',
                    'version': '13.0a1',
                })
            eq_(response.data, {'crashtrends': []})
Exemplo n.º 22
0
    def test_adu_by_signature(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server, '/crashes/adu_by_signature/', {
                    'start_date': '2012-03-01',
                    'end_date': '2012-03-15',
                    'signature': 'FakeSignature1',
                    'channel': 'aurora',
                })
            eq_(response.data, {'hits': [], 'total': 0})
Exemplo n.º 23
0
    def test_signaturesummary(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server, '/signaturesummary/', {
                    'report_type': 'products',
                    'signature': 'sig+nature',
                    'start_date': '2012-02-29T01:23:45+00:00',
                    'end_date': '2012-02-29T01:23:45+00:00',
                    'versions': [1, 2],
                })
            eq_(response.data, [])
Exemplo n.º 24
0
    def test_signatureurls(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server, '/signatureurls/', {
                    'signature': 'samplesignature',
                    'start_date': '2012-03-01T00:00:00+00:00',
                    'end_date': '2012-03-31T00:00:00+00:00',
                    'products': ['Firefox', 'Fennec'],
                    'versions': ['Firefox:4.0.1', 'Fennec:13.0'],
                })
            eq_(response.data, {'hits': [], 'total': 0})
Exemplo n.º 25
0
    def test_setting_up_with_lists_overridden(self):

        platforms = [{'id': 'amiga', 'name': 'Amiga'}]
        platforms_json_dump = json.dumps(platforms)

        config_manager = self._setup_config_manager(
            extra_value_source={
                'webapi.non_release_channels': 'Foo, Bar',
                'webapi.restricted_channels': 'foo , bar',
                'webapi.platforms': platforms_json_dump
            })

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            eq_(app.config.webapi.non_release_channels, ['Foo', 'Bar'])
            eq_(app.config.webapi.restricted_channels, ['foo', 'bar'])
            eq_(app.config.webapi.platforms, platforms)
Exemplo n.º 26
0
    def test_search_with_double_encoded_slash(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server, '/signatureurls/signature/%s/'
                'start_date/2012-03-01T00:00:00+00:00/'
                'end_date/2012-03-31T00:00:00+00:00/'
                'products/Firefox+Fennec/versions/Firefox:4.0.1+Fennec:13.0/' %
                double_encode('+samplesignat/ure'))
            self.assertEqual(response.data, {'hits': [], 'total': 0})

            response = self.post(server, '/bugs/',
                                 {'signatures': '%2Fsign1%2B'})
            self.assertEqual(response.data, {'hits': [], u'total': 0})
Exemplo n.º 27
0
    def test_search(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server, '/search/crashes/', {
                    'for': 'libflash.so',
                    'in': 'signature',
                    'products': 'Firefox',
                    'versions': 'Firefox:4.0.1',
                    'from': '2011-05-01',
                    'to': '2011-05-05',
                    'os': 'Windows',
                })
            eq_(response.data, {'hits': [], 'total': 0})
Exemplo n.º 28
0
    def test_crashes_comments_with_data(self):
        config_manager = self._setup_config_manager()

        now = datetimeutil.utc_now()
        uuid = "%%s-%s" % now.strftime("%y%m%d")
        cursor = self.conn.cursor()
        cursor.execute(
            """
            INSERT INTO reports
            (id, date_processed, uuid, signature, user_comments)
            VALUES
            (
                1,
                %s,
                %s,
                'sig1',
                'crap'
            ),
            (
                2,
                %s,
                %s,
                'sig2',
                'great'
            );
        """, (now, uuid % "a1", now, uuid % "a2"))
        self.conn.commit()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(
                server,
                '/crashes/comments/signature/%s/from/%s/to/%s/' % (
                    'sig1',
                    #(now - datetime.timedelta(days=1)).strftime('%Y-%m-%d'),
                    now,
                    now))
            self.assertEqual(response.data['total'], 1)
            self.assertEqual(response.data['hits'][0]['user_comments'], 'crap')
Exemplo n.º 29
0
    def test_post_product(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.post(server, '/products/', {
                'product': 'KillerApp',
                'version': '1.0',
            })
            eq_(response.data, True)

            # do it a second time
            response = self.post(server, '/products/', {
                'product': 'KillerApp',
                'version': '1.0',
            })
            eq_(response.data, False)
Exemplo n.º 30
0
    def test_missing_argument_yield_bad_request(self):
        config_manager = self._setup_config_manager()

        with config_manager.context() as config:
            app = middleware_app.MiddlewareApp(config)
            app.main()
            server = middleware_app.application

            response = self.get(server, '/priorityjobs/', expect_errors=True)
            eq_(response.status, 500)

            response = self.post(server, '/priorityjobs/', expect_errors=True)
            eq_(response.status, 400)

            response = self.post(
                server,
                '/priorityjobs/',
                {'uuid': 1234689},
            )
            eq_(response.status, 200)