def setUp(self): app.config["DEBUG"] = True app.config["SPECIAL_FORCE_HOSTS"] = ("http://a.com",) app.config["WHITELISTED_DOMAINS"] = {"a.com": ("a", "b", "c")} dbo.setDb("sqlite:///:memory:") dbo.create() self.client = app.test_client() dbo.setDomainWhitelist({"a.com": ("a", "b", "c")}) dbo.rules.t.insert().execute(priority=90, backgroundRate=100, mapping="a", update_type="minor", product="a", data_version=1) dbo.releases.t.insert().execute(name="a", product="a", data_version=1, data=createBlob(""" { "name": "a", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "2", "locales": { "l": { "complete": { "filesize": "3", "from": "*", "hashValue": "4", "fileUrl": "http://a.com/z" } } } } } } """)) dbo.rules.t.insert().execute(priority=90, backgroundRate=100, mapping="b", update_type="minor", product="b", mig64=True, data_version=1) dbo.releases.t.insert().execute(name="b", product="b", data_version=1, data=createBlob(""" { "name": "b", "schema_version": 1, "appv": "2.0", "extv": "2.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "12", "locales": { "l": { "complete": { "filesize": "13", "from": "*", "hashValue": "14", "fileUrl": "http://a.com/z1" } } } } } } """)) dbo.rules.t.insert().execute(priority=90, backgroundRate=100, mapping="c", update_type="minor", product="c", mig64=False, data_version=1) dbo.releases.t.insert().execute(name="c", product="c", data_version=1, data=createBlob(""" { "name": "c", "schema_version": 1, "appv": "3.0", "extv": "3.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "22", "locales": { "l": { "complete": { "filesize": "23", "from": "*", "hashValue": "24", "fileUrl": "http://a.com/z2" } } } } } } """))
def setUp(self): dbo.setDb('sqlite:///:memory:') self.metadata.create_all(dbo.engine) self.client = app.test_client()
def setUp(self): app.config['DEBUG'] = True app.config["WHITELISTED_DOMAINS"] = {"a.com": ("a",)} dbo.setDb('sqlite:///:memory:') dbo.create() self.client = app.test_client()
def setUp(self): self.version_fd, self.version_file = mkstemp() app.config['DEBUG'] = True app.config['SPECIAL_FORCE_HOSTS'] = ('http://a.com',) app.config['WHITELISTED_DOMAINS'] = {'a.com': ('b', 'c', 'e', 'f', 'response-a', 'response-b', 's', 'responseblob-a', 'responseblob-b', 'q', 'fallback')} app.config["VERSION_FILE"] = self.version_file with open(self.version_file, "w+") as f: f.write(""" { "source":"https://github.com/mozilla/balrog", "version":"1.0", "commit":"abcdef123456" } """) dbo.setDb('sqlite:///:memory:') dbo.create() dbo.setDomainWhitelist({'a.com': ('b', 'c', 'e')}) self.client = app.test_client() dbo.permissions.t.insert().execute(permission='admin', username='******', data_version=1) dbo.rules.t.insert().execute(priority=90, backgroundRate=100, mapping='b', update_type='minor', product='b', data_version=1, alias="moz-releng") dbo.releases.t.insert().execute(name='b', product='b', data_version=1, data=createBlob(""" { "name": "b", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "2", "locales": { "l": { "complete": { "filesize": "3", "from": "*", "hashValue": "4", "fileUrl": "http://a.com/z" } }, "xh": { "complete": { "filesize": "5", "from": "*", "hashValue": "6", "fileUrl": "http://a.com/x" } } } } } } """)) dbo.rules.t.insert().execute(priority=90, backgroundRate=100, mapping='s', update_type='minor', product='s', instructionSet="SSE", data_version=1) dbo.releases.t.insert().execute(name='s', product='s', data_version=1, data=createBlob(""" { "name": "s", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "5", "locales": { "l": { "complete": { "filesize": "5", "from": "*", "hashValue": "5", "fileUrl": "http://a.com/s" } } } } } } """)) dbo.rules.t.insert().execute(priority=90, backgroundRate=0, mapping='q', update_type='minor', product='q', fallbackMapping='fallback', data_version=1) dbo.releases.t.insert().execute(name='q', product='q', data_version=1, data=createBlob(""" { "name": "q", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "5", "locales": { "l": { "complete": { "filesize": "5", "from": "*", "hashValue": "5", "fileUrl": "http://a.com/q" } } } } } } """)) dbo.releases.t.insert().execute(name='fallback', product='q', data_version=1, data=createBlob(""" { "name": "fallback", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "5", "locales": { "l": { "complete": { "filesize": "5", "from": "*", "hashValue": "5", "fileUrl": "http://a.com/fallback" } } } } } } """)) dbo.rules.t.insert().execute(priority=90, backgroundRate=100, mapping='c', update_type='minor', product='c', distribution='default', data_version=1) dbo.releases.t.insert().execute(name='c', product='c', data_version=1, data=createBlob(""" { "name": "c", "schema_version": 1, "appv": "10.0", "extv": "10.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "11", "locales": { "l": { "complete": { "filesize": "12", "from": "*", "hashValue": "13", "fileUrl": "http://a.com/y" } } } } } } """)) dbo.rules.t.insert().execute(priority=90, backgroundRate=100, mapping='d', update_type='minor', product='d', data_version=1) dbo.releases.t.insert().execute(name='d', product='d', data_version=1, data=createBlob(""" { "name": "d", "schema_version": 1, "appv": "20.0", "extv": "20.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "21", "locales": { "l": { "complete": { "filesize": 22, "from": "*", "hashValue": "23", "fileUrl": "http://evil.com/y" } } } } } } """)) dbo.rules.t.insert().execute(priority=90, backgroundRate=0, mapping='e', update_type='minor', product='e', data_version=1) dbo.releases.t.insert().execute(name='e', product='e', data_version=1, data=createBlob(""" { "name": "e", "schema_version": 1, "hashFunction": "sha512", "platforms": { "p": { "buildID": "25", "locales": { "l": { "complete": { "filesize": 22, "from": "*", "hashValue": "23", "fileUrl": "http://a.com/y" } } } } } } """)) dbo.rules.t.insert().execute(priority=90, backgroundRate=100, mapping="f", update_type="minor", product="f", channel="a", memory="<=8000", data_version=1) dbo.rules.t.insert().execute(priority=90, backgroundRate=100, mapping="f", update_type="minor", product="f", channel="b", memory="9000", data_version=1) dbo.rules.t.insert().execute(priority=90, backgroundRate=100, mapping="f", update_type="minor", product="f", channel="c", memory=">10000", data_version=1) dbo.releases.t.insert().execute(name="f", product="f", data_version=1, data=createBlob(""" { "name": "f", "schema_version": 1, "hashFunction": "sha512", "appv": "1.0", "extv": "1.0", "platforms": { "p": { "buildID": "35", "locales": { "l": { "complete": { "filesize": 33, "from": "*", "hashValue": "34", "fileUrl": "http://a.com/f" } } } } } } """)) dbo.rules.t.insert().execute(priority=200, backgroundRate=100, mapping='gmp', update_type='minor', product='gmp', data_version=1) dbo.rules.t.insert().execute(priority=200, backgroundRate=100, mapping='gmp-with-one-response-product', update_type='minor', product='gmp-with-one-response-product', data_version=1) dbo.rules.t.insert().execute(priority=190, backgroundRate=100, mapping='response-a', update_type='minor', product='response-a', data_version=1) dbo.rules.t.insert().execute(priority=180, backgroundRate=100, mapping='response-b', update_type='minor', product='response-b', data_version=1) dbo.releases.t.insert().execute(name='gmp-with-one-response-product', product='gmp-with-one-response-product', data_version=1, data=createBlob(""" { "name": "superblob", "schema_version": 4000, "products": ["response-a"] } """)) dbo.releases.t.insert().execute(name='gmp', product='gmp', data_version=1, data=createBlob(""" { "name": "superblob", "schema_version": 4000, "products": ["response-a", "response-b"] } """)) dbo.releases.t.insert().execute(name='response-a', product='response-a', data_version=1, data=createBlob(""" { "name": "response-a", "schema_version": 1, "extv": "2.5", "hashFunction": "sha512", "platforms": { "p": { "buildID": "25", "locales": { "l": { "complete": { "filesize": 22, "from": "*", "hashValue": "23", "fileUrl": "http://a.com/public" } } } }, "q": { "buildID": "25", "locales": { "l": { "complete": { "filesize": 22, "from": "*", "hashValue": "23", "fileUrl": "http://a.com/public-q" } } } } } } """)) dbo.releases.t.insert().execute(name='response-b', product='response-b', data_version=1, data=createBlob(""" { "name": "response-b", "schema_version": 1, "extv": "2.5", "hashFunction": "sha512", "platforms": { "p": { "buildID": "25", "locales": { "l": { "complete": { "filesize": 27777777, "from": "*", "hashValue": "23", "fileUrl": "http://a.com/b" } } } } } } """)) dbo.rules.t.insert().execute(priority=180, backgroundRate=100, mapping='systemaddons-uninstall', update_type='minor', product='systemaddons-uninstall', data_version=1) dbo.releases.t.insert().execute(name='systemaddons-uninstall', product='systemaddons-uninstall', data_version=1, data=createBlob(""" { "name": "fake", "schema_version": 5000, "hashFunction": "SHA512", "uninstall": true } """)) dbo.rules.t.insert().execute(priority=180, backgroundRate=100, mapping='systemaddons', update_type='minor', product='systemaddons', data_version=1) dbo.releases.t.insert().execute(name='systemaddons', product='systemaddons', data_version=1, data=createBlob(""" { "name": "fake", "schema_version": 5000, "hashFunction": "SHA512", "uninstall": false, "addons": { "c": { "version": "1", "platforms": { "p": { "filesize": 2, "hashValue": "3", "fileUrl": "http://a.com/blah" } } } } } """)) dbo.rules.t.insert().execute(priority=1000, backgroundRate=0, mapping='product_that_should_not_be_updated-1.1', update_type='minor', product='product_that_should_not_be_updated', data_version=1) dbo.releases.t.insert().execute(name='product_that_should_not_be_updated-1.1', product='product_that_should_not_be_updated', data_version=1, data=createBlob(""" { "name": "product_that_should_not_be_updated-1.1", "schema_version": 1, "appv": "1.1", "extv": "1.1", "hashFunction": "sha512", "platforms": { "p": { "buildID": "2", "locales": { "l": { "complete": { "filesize": "3", "from": "*", "hashValue": "4", "fileUrl": "http://a.com/z" } } } } } } """)) dbo.rules.t.insert().execute(priority=90, backgroundRate=100, mapping='product_that_should_not_be_updated-2.0', update_type='minor', product='product_that_should_not_be_updated', data_version=1) dbo.releases.t.insert().execute(name='product_that_should_not_be_updated-2.0', product='product_that_should_not_be_updated', data_version=1, data=createBlob(""" { "name": "product_that_should_not_be_updated-2.0", "schema_version": 1, "appv": "2.0", "extv": "2.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "2", "locales": { "l": { "complete": { "filesize": "3", "from": "*", "hashValue": "4", "fileUrl": "http://a.com/z" } } } } } } """)) dbo.rules.t.insert().execute(priority=200, backgroundRate=100, mapping='superblobaddon-with-multiple-response-blob', update_type='minor', product='superblobaddon-with-multiple-response-blob', data_version=1) dbo.rules.t.insert().execute(priority=200, backgroundRate=100, mapping='superblobaddon-with-one-response-blob', update_type='minor', product='superblobaddon-with-one-response-blob', data_version=1) dbo.releases.t.insert().execute(name='superblobaddon-with-one-response-blob', product='superblobaddon-with-one-response-blob', data_version=1, data=createBlob(""" { "name": "superblobaddon", "schema_version": 4000, "blobs": ["responseblob-a"] } """)) dbo.releases.t.insert().execute(name='superblobaddon-with-multiple-response-blob', product='superblobaddon-with-multiple-response-blob', data_version=1, data=createBlob(""" { "name": "superblobaddon", "schema_version": 4000, "blobs": ["responseblob-a", "responseblob-b"] } """)) dbo.releases.t.insert().execute(name='responseblob-a', product='responseblob-a', data_version=1, data=createBlob(""" { "name": "responseblob-a", "schema_version": 5000, "hashFunction": "SHA512", "addons": { "c": { "version": "1", "platforms": { "p": { "filesize": 2, "hashValue": "3", "fileUrl": "http://a.com/e" }, "q": { "filesize": 4, "hashValue": "5", "fileUrl": "http://a.com/e" }, "q2": { "alias": "q" } } }, "d": { "version": "5", "platforms": { "q": { "filesize": 10, "hashValue": "11", "fileUrl": "http://a.com/c" }, "default": { "filesize": 20, "hashValue": "50", "fileUrl": "http://a.com/c" } } } } } """)) dbo.releases.t.insert().execute(name='responseblob-b', product='responseblob-b', data_version=1, data=createBlob(""" { "name": "responseblob-b", "schema_version": 5000, "hashFunction": "sha512", "uninstall": false, "addons": { "b": { "version": "1", "platforms": { "p": { "filesize": 27, "hashValue": "23", "fileUrl": "http://a.com/b" } } } } } """))
def setup(self, insert_release, firefox_54_0_1_build1, firefox_56_0_build1, superblob_e8f4a19, hotfix_bug_1548973_1_1_4, timecop_1_0): app.config["DEBUG"] = True self.public_client = app.test_client() dbo.setDb("sqlite:///:memory:") self.metadata.create_all(dbo.engine) dbo.rules.t.insert().execute(rule_id=1, priority=90, backgroundRate=100, mapping="Fennec.55.0a1", update_type="minor", product="Fennec", data_version=1, alias="moz-releng") dbo.releases.t.insert().execute( name="Fennec.55.0a1", product="Fennec", data_version=1, data=createBlob(""" { "name": "Fennec.55.0a1", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "2", "locales": { "l": { "complete": { "filesize": "3", "from": "*", "hashValue": "4", "fileUrl": "http://a.com/z" } }, "xh": { "complete": { "filesize": "5", "from": "*", "hashValue": "6", "fileUrl": "http://a.com/x" } } } } } } """), ) dbo.rules.t.insert().execute(rule_id=2, priority=90, backgroundRate=100, mapping="Firefox.55.0a1", update_type="minor", product="Firefox", instructionSet="SSE", data_version=1) dbo.releases.t.insert().execute( name="Firefox.55.0a1", product="Firefox", data_version=1, data=createBlob(""" { "name": "Firefox.55.0a1", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "5", "locales": { "l": { "buildID": "5", "complete": { "filesize": "5", "from": "*", "hashValue": "5", "fileUrl": "http://a.com/s" } } } } } } """), ) dbo.rules.t.insert().execute(rule_id=3, priority=90, backgroundRate=0, mapping="q", update_type="minor", product="q", data_version=3) dbo.rules.history.t.insert().execute(change_id=1, changed_by="usr", timestamp=10, rule_id=3, priority=90, backgroundRate=0, mapping="y", update_type="minor", product="y", data_version=2) dbo.rules.history.t.insert().execute(change_id=2, changed_by="usr", timestamp=10, rule_id=3, priority=90, backgroundRate=0, mapping="z", update_type="minor", product="z", data_version=1) dbo.releases.t.insert().execute( name="q", product="q", data_version=2, data=createBlob(""" { "name": "q", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "6", "locales": { "l": { "complete": { "filesize": "5", "from": "*", "hashValue": "5", "fileUrl": "http://a.com/q" } } } } } } """), ) dbo.rules.t.insert().execute(rule_id=4, priority=90, backgroundRate=100, mapping="Firefox.55.0a1", update_type="minor", product="Firefox", mig64=True, data_version=1) insert_release(firefox_54_0_1_build1, "Firefox", history=False) insert_release(firefox_56_0_build1, "Firefox", history=False) insert_release(superblob_e8f4a19, "SystemAddons", history=False) insert_release(hotfix_bug_1548973_1_1_4, "SystemAddons", history=False) insert_release(timecop_1_0, "SystemAddons", history=False)
def setUp(self): app.config['DEBUG'] = True self.public_client = app.test_client() dbo.setDb('sqlite:///:memory:') dbo.create() dbo.rules.t.insert().execute(rule_id=1, priority=90, backgroundRate=100, mapping='Fennec.55.0a1', update_type='minor', product='Fennec', data_version=1, alias="moz-releng") dbo.releases.t.insert().execute(name='Fennec.55.0a1', product='Fennec', data_version=1, data=createBlob(""" { "name": "Fennec.55.0a1", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "2", "locales": { "l": { "complete": { "filesize": "3", "from": "*", "hashValue": "4", "fileUrl": "http://a.com/z" } }, "xh": { "complete": { "filesize": "5", "from": "*", "hashValue": "6", "fileUrl": "http://a.com/x" } } } } } } """)) dbo.rules.t.insert().execute(rule_id=2, priority=90, backgroundRate=100, mapping='Firefox.55.0a1', update_type='minor', product='Firefox', systemCapabilities="SSE", data_version=1) dbo.releases.t.insert().execute(name='Firefox.55.0a1', product='Firefox', data_version=1, data=createBlob(""" { "name": "Firefox.55.0a1", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "5", "locales": { "l": { "buildID": "5", "complete": { "filesize": "5", "from": "*", "hashValue": "5", "fileUrl": "http://a.com/s" } } } } } } """)) dbo.rules.t.insert().execute(rule_id=3, priority=90, backgroundRate=0, mapping='q', update_type='minor', product='q', data_version=3) dbo.rules.history.t.insert().execute(change_id=1, changed_by="usr", timestamp=10, rule_id=3, priority=90, backgroundRate=0, mapping='y', update_type='minor', product='y', data_version=2) dbo.rules.history.t.insert().execute(change_id=2, changed_by="usr", timestamp=10, rule_id=3, priority=90, backgroundRate=0, mapping='z', update_type='minor', product='z', data_version=1) dbo.releases.t.insert().execute(name='q', product='q', data_version=2, data=createBlob(""" { "name": "q", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "6", "locales": { "l": { "complete": { "filesize": "5", "from": "*", "hashValue": "5", "fileUrl": "http://a.com/q" } } } } } } """)) dbo.releases.history.t.insert().execute(change_id=1, changed_by="usr", timestamp=10, name='q', product='q', data_version=1)
def setUp(self): dbo.setDb('sqlite:///:memory:') dbo.create() self.client = app.test_client()
def setUp(self): app.config['DEBUG'] = True self.public_client = app.test_client() dbo.setDb('sqlite:///:memory:') self.metadata.create_all(dbo.engine) dbo.rules.t.insert().execute(rule_id=1, priority=90, backgroundRate=100, mapping='Fennec.55.0a1', update_type='minor', product='Fennec', data_version=1, alias="moz-releng") dbo.releases.t.insert().execute(name='Fennec.55.0a1', product='Fennec', data_version=1, data=createBlob(""" { "name": "Fennec.55.0a1", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "2", "locales": { "l": { "complete": { "filesize": "3", "from": "*", "hashValue": "4", "fileUrl": "http://a.com/z" } }, "xh": { "complete": { "filesize": "5", "from": "*", "hashValue": "6", "fileUrl": "http://a.com/x" } } } } } } """)) dbo.rules.t.insert().execute(rule_id=2, priority=90, backgroundRate=100, mapping='Firefox.55.0a1', update_type='minor', product='Firefox', instructionSet="SSE", data_version=1) dbo.releases.t.insert().execute(name='Firefox.55.0a1', product='Firefox', data_version=1, data=createBlob(""" { "name": "Firefox.55.0a1", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "5", "locales": { "l": { "buildID": "5", "complete": { "filesize": "5", "from": "*", "hashValue": "5", "fileUrl": "http://a.com/s" } } } } } } """)) dbo.rules.t.insert().execute(rule_id=3, priority=90, backgroundRate=0, mapping='q', update_type='minor', product='q', data_version=3) dbo.rules.history.t.insert().execute(change_id=1, changed_by="usr", timestamp=10, rule_id=3, priority=90, backgroundRate=0, mapping='y', update_type='minor', product='y', data_version=2) dbo.rules.history.t.insert().execute(change_id=2, changed_by="usr", timestamp=10, rule_id=3, priority=90, backgroundRate=0, mapping='z', update_type='minor', product='z', data_version=1) dbo.releases.t.insert().execute(name='q', product='q', data_version=2, data=createBlob(""" { "name": "q", "schema_version": 1, "appv": "1.0", "extv": "1.0", "hashFunction": "sha512", "platforms": { "p": { "buildID": "6", "locales": { "l": { "complete": { "filesize": "5", "from": "*", "hashValue": "5", "fileUrl": "http://a.com/q" } } } } } } """)) dbo.releases.history.t.insert().execute(change_id=1, changed_by="usr", timestamp=10, name='q', product='q', data_version=1) dbo.rules.t.insert().execute(rule_id=4, priority=90, backgroundRate=100, mapping='Firefox.55.0a1', update_type='minor', product='Firefox', mig64=True, data_version=1)
def setUp(self): app.config['DEBUG'] = True app.config['WHITELISTED_DOMAINS'] = ('a.com', ) dbo.setDb('sqlite:///:memory:') dbo.create() self.client = app.test_client()
def setUp(self): dbo.setDb('sqlite:///:memory:') dbo.create() self.client = app.test_client()
def client(): return app.test_client()