Exemple #1
0
 def setUp(self):
     self.app = ApplicationFactory()
     self.a_platform = PlatformFactory(name='a')
     self.b_platform = PlatformFactory(name='b')
     self.empty_platform = PlatformFactory(name='empty')
     self.mac_platform = PlatformFactory(name='mac')
     VersionFactory(platform=self.a_platform, app=self.app)
     VersionFactory(platform=self.b_platform, app=self.app)
    def test_updatecheck_positive_critical_on_other_channel(self):
        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        channel2 = ChannelFactory.create(name='alpha')
        first_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.110',
            file=SimpleUploadedFile('./chrome_installer_first.exe', b'_' * 23963192),
            file_size=23963192)
        first_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        first_version.save()

        critical_version = VersionFactory.create(
            is_critical=True,
            app=app,
            platform=platform,
            channel=channel2,
            version='13.0.782.111',
            file=SimpleUploadedFile('./chrome_installer_critical.exe', b'_' * 23963192),
            file_size=23963192)
        critical_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        critical_version.save()

        last_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.112',
            file=SimpleUploadedFile('./chrome_installer.exe', b'_' * 23963192),
            file_size=23963192)
        last_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        last_version.save()

        Action.objects.create(
            version=last_version,
            arguments='--do-not-launch-chrome',
            event=EVENT_DICT_CHOICES['install'],
            run='chrome_installer.exe'
        )

        Action.objects.create(
            version=last_version,
            event=EVENT_DICT_CHOICES['postinstall'],
            other=dict(
                version='13.0.782.112',
                onsuccess='exitsilentlyonlaunchcmd',
            )
        )

        response = self.client.post(reverse('update'),
                                    fixtures.request_update_check, content_type='text/xml')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.response_update_check_positive)
    def test_updatecheck_positive_critical_on_other_channel(self):
        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        channel2 = ChannelFactory.create(name='alpha')
        first_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.110',
            file=SimpleUploadedFile('./chrome_installer_first.exe', b'_' * 23963192),
            file_size=23963192)
        first_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        first_version.save()

        critical_version = VersionFactory.create(
            is_critical=True,
            app=app,
            platform=platform,
            channel=channel2,
            version='13.0.782.111',
            file=SimpleUploadedFile('./chrome_installer_critical.exe', b'_' * 23963192),
            file_size=23963192)
        critical_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        critical_version.save()

        last_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.112',
            file=SimpleUploadedFile('./chrome_installer.exe', b'_' * 23963192),
            file_size=23963192)
        last_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        last_version.save()

        Action.objects.create(
            version=last_version,
            arguments='--do-not-launch-chrome',
            event=EVENT_DICT_CHOICES['install'],
            run='chrome_installer.exe'
        )

        Action.objects.create(
            version=last_version,
            event=EVENT_DICT_CHOICES['postinstall'],
            other=dict(
                version='13.0.782.112',
                onsuccess='exitsilentlyonlaunchcmd',
            )
        )

        response = self.client.post(reverse('update'),
                                    fixtures.request_update_check, content_type='text/xml')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.response_update_check_positive)
Exemple #4
0
    def test_data(self):
        app = ApplicationFactory.create(
            id='{430FD4D0-B729-4F61-AA34-91526481799D}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        obj = VersionFactory.create(app=app,
                                    platform=platform,
                                    channel=channel,
                                    version='13.0.782.112',
                                    file=SimpleUploadedFile(
                                        './chrome_installer.exe',
                                        b'_' * 23963192),
                                    file_size=23963192)
        obj.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        obj.save()

        Data.objects.create(app=app,
                            name=NAME_DATA_DICT_CHOICES['install'],
                            index='verboselogging',
                            value='app-specific values here')

        Data.objects.create(app=app, name=NAME_DATA_DICT_CHOICES['untrusted'])

        response = self.client.post(reverse('update'),
                                    fixtures.request_data,
                                    content_type='text/xml')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.response_data)
    def test_data(self):
        app = ApplicationFactory.create(id='{430FD4D0-B729-4F61-AA34-91526481799D}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        obj = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.112',
            file=SimpleUploadedFile('./chrome_installer.exe', b'_' * 23963192),
            file_size=23963192)
        obj.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        obj.save()

        Data.objects.create(
            app=app,
            name=NAME_DATA_DICT_CHOICES['install'],
            index='verboselogging',
            value='app-specific values here')

        Data.objects.create(
            app=app,
            name=NAME_DATA_DICT_CHOICES['untrusted'])

        response = self.client.post(reverse('update'),
                                    fixtures.request_data, content_type='text/xml')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.response_data)
Exemple #6
0
    def test_userid_counting(self):
        now = datetime.utcnow()
        userid = '{D0BBD725-742D-44ae-8D46-0231E881D58E}'
        user_id = get_id(userid)
        appid1 = '{430FD4D0-B729-4F61-AA34-91526481799D}'
        appid2 = '{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}'

        request_events = DayEvents('request', now.year, now.month, now.day)
        app1_events = DayEvents('request:%s' % appid1, now.year, now.month, now.day)
        app2_events = DayEvents('request:%s' % appid2, now.year, now.month, now.day)

        self.assertEqual(len(request_events), 0)
        self.assertEqual(len(app1_events), 0)
        self.assertEqual(len(app2_events), 0)


        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        obj = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.112',
            file=SimpleUploadedFile('./chrome_installer.exe', b'_' * 23963192))
        obj.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        obj.save()

        Action.objects.create(
            version=obj,
            arguments='--do-not-launch-chrome',
            event=EVENT_DICT_CHOICES['install'],
            run='chrome_installer.exe'
        )

        Action.objects.create(
            version=obj,
            event=EVENT_DICT_CHOICES['postinstall'],
            other=dict(
                version='13.0.782.112',
                onsuccess='exitsilentlyonlaunchcmd',
            )
        )

        self.client.post(reverse('update'),
                         fixtures.request_update_check, content_type='text/xml')

        self.assertEqual(len(request_events), 1)
        self.assertEqual(len(app1_events), 1)
        self.assertEqual(len(app2_events), 1)
        self.assertTrue(user_id in request_events)
        self.assertTrue(user_id in app1_events)
        self.assertTrue(user_id in app2_events)
Exemple #7
0
    def test_userid_counting(self):
        now = datetime.utcnow()
        userid = '{D0BBD725-742D-44ae-8D46-0231E881D58E}'
        user_id = get_id(userid)
        appid1 = '{430FD4D0-B729-4F61-AA34-91526481799D}'
        appid2 = '{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}'

        request_events = DayEvents('request', now.year, now.month, now.day)
        app1_events = DayEvents('request:%s' % appid1, now.year, now.month,
                                now.day)
        app2_events = DayEvents('request:%s' % appid2, now.year, now.month,
                                now.day)

        self.assertEqual(len(request_events), 0)
        self.assertEqual(len(app1_events), 0)
        self.assertEqual(len(app2_events), 0)

        app = ApplicationFactory.create(
            id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        obj = VersionFactory.create(app=app,
                                    platform=platform,
                                    channel=channel,
                                    version='13.0.782.112',
                                    file=SimpleUploadedFile(
                                        './chrome_installer.exe',
                                        b'_' * 23963192))
        obj.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        obj.save()

        Action.objects.create(version=obj,
                              arguments='--do-not-launch-chrome',
                              event=EVENT_DICT_CHOICES['install'],
                              run='chrome_installer.exe')

        Action.objects.create(version=obj,
                              event=EVENT_DICT_CHOICES['postinstall'],
                              other=dict(
                                  version='13.0.782.112',
                                  onsuccess='exitsilentlyonlaunchcmd',
                              ))

        self.client.post(reverse('update'),
                         fixtures.request_update_check,
                         content_type='text/xml')

        self.assertEqual(len(request_events), 1)
        self.assertEqual(len(app1_events), 1)
        self.assertEqual(len(app2_events), 1)
        self.assertTrue(user_id in request_events)
        self.assertTrue(user_id in app1_events)
        self.assertTrue(user_id in app2_events)
Exemple #8
0
 def test_create(self):
     data = dict(
         app=ApplicationFactory.create().id,
         platform=PlatformFactory.create().id,
         channel=ChannelFactory.create().id,
         version='1.2.3.4',
         file=SimpleUploadedFile("chrome.exe", b'content'),
     )
     response = self.client.post(self.url, data)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     version = Version.objects.get(id=response.data['id'])
     self.assertEqual(response.data, self.serializer(version).data)
     self.assertEqual(version.file_size, len(b'content'))
Exemple #9
0
 def test_create(self):
     data = dict(
         app=ApplicationFactory.create().id,
         platform=PlatformFactory.create().id,
         channel=ChannelFactory.create().id,
         version='1.2.3.4',
         file=SimpleUploadedFile("chrome.exe", b'content'),
     )
     response = self.client.post(self.url, data)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     version = Version.objects.get(id=response.data['id'])
     self.assertEqual(response.data, self.serializer(version).data)
     self.assertEqual(version.file_size, len(b'content'))
Exemple #10
0
    def test_updatecheck_positive_critical(self):
        app = ApplicationFactory.create(
            id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        first_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.110',
            file=SimpleUploadedFile('./chrome_installer_first.exe',
                                    b'_' * 23963192),
            file_size=23963192)
        first_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        first_version.save()

        critical_version = VersionFactory.create(
            is_critical=True,
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.111',
            file=SimpleUploadedFile('./chrome_installer_critical.exe',
                                    b'_' * 23963192),
            file_size=23963192)
        critical_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        critical_version.save()

        last_version = VersionFactory.create(app=app,
                                             platform=platform,
                                             channel=channel,
                                             version='13.0.782.112',
                                             file=SimpleUploadedFile(
                                                 './chrome_installer.exe',
                                                 b'_' * 23963192),
                                             file_size=23963192)
        last_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        last_version.save()

        response = self.client.post(reverse('update'),
                                    fixtures.request_update_check,
                                    content_type='text/xml')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(
            response.content,
            fixtures.response_update_check_postitive_critical)
Exemple #11
0
    def setUp(self):
        self.app = ApplicationFactory(name='TestApp')
        self.platform = PlatformFactory(name='win')
        self.channel = ChannelFactory(name='alpha')
        self.stable_channel = ChannelFactory(name='stable')
        self.win_v1 = VersionFactory(version='10.0.0.0', app=self.app, channel=self.channel, platform=self.platform)
        self.win_v2 = VersionFactory(version='42.0.1.0', app=self.app, channel=self.channel, platform=self.platform)
        self.win_stable_v = VersionFactory(version='23.0.0.0', app=self.app,
                                           channel=self.stable_channel, platform=self.platform)
        self.win_disabled_v = VersionFactory(version='55.0.2.0', app=self.app, channel=self.channel,
                                             platform=self.platform, is_enabled=False)

        self.mac_v1 = SparkleVersionFactory(short_version='10.0.0.0', version='0.0',
                                            app=self.app, channel=self.channel)
        self.mac_v2 = SparkleVersionFactory(short_version='42.0.1.0', version='1.0',
                                            app=self.app, channel=self.channel)
        self.mac_stable_v = SparkleVersionFactory(short_version='23.0.0.0', version='0.0',
                                                  app=self.app, channel=self.stable_channel)
        self.mac_disabled_v = SparkleVersionFactory(short_version='55.0.2.0', version='2.0',
                                                    app=self.app, channel=self.channel, is_enabled=False)
        self.exp_res = {
            self.app.name: {
                "win": {
                    self.channel.name: {
                        "url": self.win_v2.file_absolute_url,
                        "version": self.win_v2.version
                    },
                    self.stable_channel.name: {
                        "url": self.win_stable_v.file_absolute_url,
                        "version": self.win_stable_v.version
                    }
                },
                "mac": {
                    self.channel.name: {
                        "url": self.mac_v2.file_absolute_url,
                        "version": self.mac_v2.short_version
                    },
                    self.stable_channel.name: {
                        "url": self.mac_stable_v.file_absolute_url,
                        "version": self.mac_stable_v.short_version
                    }
                }
            }
        }
Exemple #12
0
    def test_updatecheck_positive_critical(self):
        app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')
        platform = PlatformFactory.create(name='win')
        channel = ChannelFactory.create(name='stable')
        first_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.110',
            file=SimpleUploadedFile('./chrome_installer_first.exe', b'_' * 23963192),
            file_size=23963192)
        first_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        first_version.save()

        critical_version = VersionFactory.create(
            is_critical=True,
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.111',
            file=SimpleUploadedFile('./chrome_installer_critical.exe', b'_' * 23963192),
            file_size=23963192)
        critical_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        critical_version.save()

        last_version = VersionFactory.create(
            app=app,
            platform=platform,
            channel=channel,
            version='13.0.782.112',
            file=SimpleUploadedFile('./chrome_installer.exe', b'_' * 23963192),
            file_size=23963192)
        last_version.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='
        last_version.save()

        response = self.client.post(reverse('update'),
                                    fixtures.request_update_check, content_type='text/xml')

        self.assertEqual(response.status_code, 200)

        self.assertXmlDocument(response.content)
        self.assertXmlEquivalentOutputs(response.content,
                                        fixtures.response_update_check_postitive_critical)
Exemple #13
0
 def test_update(self):
     data = dict(
         app=ApplicationFactory.create().id,
         platform=PlatformFactory.create().id,
         channel=ChannelFactory.create().id,
         version='1.2.3.4',
         file=SimpleUploadedFile("chrome.exe", b'content'),
         is_enabled=False,
     )
     response = self.client.post(reverse(self.url), data)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     obj_id = response.data['id']
     version = Version.objects.get(id=obj_id)
     self.assertEqual(version.file_size, len(b'content'))
     self.assertFalse(version.is_enabled)
     url = reverse(self.url_detail, kwargs=dict(pk=obj_id))
     response = self.client.patch(url, dict(is_enabled=True))
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     version = Version.objects.get(id=obj_id)
     self.assertEqual(version.file_size, len(b'content'))
     self.assertTrue(version.is_enabled)
Exemple #14
0
 def test_update(self):
     data = dict(
         app=ApplicationFactory.create().id,
         platform=PlatformFactory.create().id,
         channel=ChannelFactory.create().id,
         version='1.2.3.4',
         file=SimpleUploadedFile("chrome.exe", b'content'),
         is_enabled=False,
     )
     response = self.client.post(reverse(self.url), data)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     obj_id = response.data['id']
     version = Version.objects.get(id=obj_id)
     self.assertEqual(version.file_size, len(b'content'))
     self.assertFalse(version.is_enabled)
     url = reverse(self.url_detail, kwargs=dict(pk=obj_id))
     response = self.client.patch(url, dict(is_enabled=True))
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     version = Version.objects.get(id=obj_id)
     self.assertEqual(version.file_size, len(b'content'))
     self.assertTrue(version.is_enabled)
Exemple #15
0
 def test_factory(self):
     platform = PlatformFactory.create()
     self.assertTrue(Platform.objects.get(id=platform.id))
Exemple #16
0
 def test_serializer(self):
     data = dict(name='win')
     platform = PlatformFactory(**data)
     self.assertDictEqual(
         PlatformSerializer(platform).data, dict(id=platform.pk, **data))
Exemple #17
0
 def test_factory(self):
     platform = PlatformFactory.create()
     self.assertTrue(Platform.objects.get(id=platform.id))