コード例 #1
0
ファイル: test_client.py プロジェクト: andreja-cliqz/balrog
 def setUp(self):
     app.config['DEBUG'] = True
     app.config['WHITELISTED_DOMAINS'] = ('a.com', )
     dbo.setDb('sqlite:///:memory:')
     dbo.create()
     self.client = app.test_client()
     self.view = ClientRequestView()
コード例 #2
0
ファイル: test_client.py プロジェクト: nthomas-mozilla/balrog
 def setUp(self):
     app.config["DEBUG"] = True
     app.config["WHITELISTED_DOMAINS"] = ("a.com",)
     dbo.setDb("sqlite:///:memory:")
     dbo.create()
     self.client = app.test_client()
     self.view = ClientRequestView()
コード例 #3
0
ファイル: test_client.py プロジェクト: garbas/balrog
 def setUp(self):
     app.config['DEBUG'] = True
     app.config['WHITELISTED_DOMAINS'] = ('a.com',)
     dbo.setDb('sqlite:///:memory:')
     dbo.create()
     self.client = app.test_client()
     self.view = ClientRequestView()
コード例 #4
0
ファイル: base.py プロジェクト: lsblakk/balrog
 def setUp(self):
     app.config['SECRET_KEY'] = 'abc123'
     app.config['DEBUG'] = True
     db.setDburi('sqlite:///:memory:')
     db.permissions.t.insert().execute(permission='admin', username='******', data_version=1)
     db.permissions.t.insert().execute(permission='/users/:id/permissions/:permission', username='******', data_version=1)
     db.permissions.t.insert().execute(permission='/releases/:name', username='******', options=json.dumps(dict(product='fake')), data_version=1)
     db.releases.t.insert().execute(name='a', product='a', version='a', data=json.dumps(dict(one=1)), data_version=1)
     db.releases.t.insert().execute(name='ab', product='a', version='a', data=json.dumps(dict(one=1)), data_version=1)
     db.releases.t.insert().execute(name='b', product='b', version='b', data=json.dumps(dict(two=2)), data_version=1)
     db.releases.t.insert().execute(name='c', product='c', version='c', data=json.dumps(dict(three=3)), data_version=1)
     db.rules.t.insert().execute(id=1, priority=100, version='3.5', buildTarget='d', throttle=100, mapping='c', update_type='minor', data_version=1)
     db.rules.t.insert().execute(id=2, priority=100, version='3.3', buildTarget='d', throttle=100, mapping='b', update_type='minor', data_version=1)
     db.rules.t.insert().execute(id=3, priority=100, version='3.5', buildTarget='a', throttle=100, mapping='a', update_type='minor', data_version=1)
     db.rules.t.insert().execute(id=4, priority=80, buildTarget='d', throttle=100, mapping='a', update_type='minor', data_version=1)
     db.rules.t.insert().execute(id=5, priority=80, buildTarget='d', version='3.3', throttle=0, mapping='c', update_type='minor', data_version=1)
     self.client = app.test_client()
コード例 #5
0
ファイル: test_client.py プロジェクト: andreja-cliqz/balrog
    def setUp(self):
        self.cef_fd, self.cef_file = mkstemp()
        app.config['DEBUG'] = True
        app.config['SPECIAL_FORCE_HOSTS'] = ('http://a.com', )
        app.config['WHITELISTED_DOMAINS'] = ('a.com', 'boring.com')
        dbo.setDb('sqlite:///:memory:')
        dbo.create()
        dbo.setDomainWhitelist(('a.com', 'boring.com'))
        self.client = app.test_client()
        self.view = ClientRequestView()
        auslib.log.cef_config = auslib.log.get_cef_config(self.cef_file)
        dbo.rules.t.insert().execute(backgroundRate=100,
                                     mapping='b',
                                     update_type='minor',
                                     product='b',
                                     data_version=1)
        dbo.releases.t.insert().execute(name='b',
                                        product='b',
                                        version='1.0',
                                        data_version=1,
                                        data="""
{
    "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(backgroundRate=100,
                                     mapping='c',
                                     update_type='minor',
                                     product='c',
                                     distribution='default',
                                     data_version=1)
        dbo.releases.t.insert().execute(name='c',
                                        product='c',
                                        version='10.0',
                                        data_version=1,
                                        data="""
{
    "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(backgroundRate=100,
                                     mapping='d',
                                     update_type='minor',
                                     product='d',
                                     data_version=1)
        dbo.releases.t.insert().execute(name='d',
                                        product='d',
                                        version='20.0',
                                        data_version=1,
                                        data="""
{
    "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(backgroundRate=100,
                                     mapping='e',
                                     update_type='minor',
                                     product='e',
                                     data_version=1)
        dbo.releases.t.insert().execute(name='e',
                                        product='e',
                                        version='22.0',
                                        data_version=1,
                                        data="""
{
    "name": "e",
    "schema_version": 1,
    "hashFunction": "sha512",
    "platforms": {
        "p": {
            "buildID": "25",
            "locales": {
                "l": {
                    "complete": {
                        "filesize": 22,
                        "from": "*",
                        "hashValue": "23",
                        "fileUrl": "http://a.com/y"
                    }
                }
            }
        }
    }
}
""")
コード例 #6
0
    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', 'b2g', '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', 'b2g')})
        self.client = app.test_client()
        self.view = ClientRequestView()
        dbo.rules.t.insert().execute(priority=90,
                                     backgroundRate=100,
                                     mapping='b',
                                     update_type='minor',
                                     product='b',
                                     data_version=1)
        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',
                                     systemCapabilities="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=100,
                                     backgroundRate=100,
                                     mapping='foxfood-whitelisted',
                                     update_type='minor',
                                     product='b2g',
                                     whitelist='b2g-whitelist',
                                     data_version=1)
        dbo.rules.t.insert().execute(priority=90,
                                     backgroundRate=100,
                                     mapping='foxfood-whitelisted',
                                     update_type='minor',
                                     product='b2g',
                                     channel="foxfood",
                                     whitelist='b2g-whitelist',
                                     data_version=1)
        dbo.rules.t.insert().execute(priority=80,
                                     backgroundRate=100,
                                     mapping='foxfood-fallback',
                                     update_type='minor',
                                     product='b2g',
                                     data_version=1)
        dbo.releases.t.insert().execute(name='b2g-whitelist',
                                        product='b2g',
                                        data_version=1,
                                        data=createBlob("""
{
  "name": "b2g-whitelist",
  "schema_version": 3000,
  "whitelist": [
    { "imei": "000000000000000" },
    { "imei": "000000000000001" },
    { "imei": "000000000000002" }
  ]
}
"""))

        dbo.releases.t.insert().execute(name='foxfood-whitelisted',
                                        product='b2g',
                                        data_version=1,
                                        data=createBlob("""
{
    "name": "foxfood-whitelisted",
    "schema_version": 1,
    "extv": "2.5",
    "hashFunction": "sha512",
    "platforms": {
        "p": {
            "buildID": "25",
            "locales": {
                "l": {
                    "complete": {
                        "filesize": 22,
                        "from": "*",
                        "hashValue": "23",
                        "fileUrl": "http://a.com/secrets"
                    }
                }
            }
        }
    }
}
"""))
        dbo.releases.t.insert().execute(name='foxfood-fallback',
                                        product='b2g',
                                        data_version=1,
                                        data=createBlob("""
{
    "name": "foxfood-fallback",
    "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"
                    }
                }
            }
        }
    }
}
"""))
        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,
    "revision": 123,
    "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,
    "revision": 124,
    "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"

                }
            }
        }
    }
}
"""))
コード例 #7
0
ファイル: test_client.py プロジェクト: garbas/balrog
    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', 'b2g', 'response-a', 'response-b', 's')}
        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', 'b2g')})
        self.client = app.test_client()
        self.view = ClientRequestView()
        dbo.rules.t.insert().execute(backgroundRate=100, mapping='b', update_type='minor', product='b',
                                     data_version=1)
        dbo.releases.t.insert().execute(name='b', product='b', data_version=1, data="""
{
    "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(backgroundRate=100, mapping='s', update_type='minor', product='s',
                                     systemCapabilities="SSE", data_version=1)
        dbo.releases.t.insert().execute(name='s', product='s', data_version=1, data="""
{
    "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(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="""
{
    "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(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="""
{
    "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(backgroundRate=100, mapping='e', update_type='minor', product='e', data_version=1)
        dbo.releases.t.insert().execute(name='e', product='e', data_version=1, data="""
{
    "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=100, backgroundRate=100, mapping='foxfood-whitelisted', update_type='minor', product='b2g',
                                     whitelist='b2g-whitelist', data_version=1)
        dbo.rules.t.insert().execute(priority=90, backgroundRate=100, mapping='foxfood-whitelisted', update_type='minor', product='b2g',
                                     channel="foxfood", whitelist='b2g-whitelist', data_version=1)
        dbo.rules.t.insert().execute(priority=80, backgroundRate=100, mapping='foxfood-fallback', update_type='minor', product='b2g', data_version=1)
        dbo.releases.t.insert().execute(name='b2g-whitelist', product='b2g', data_version=1, data="""
{
  "name": "b2g-whitelist",
  "schema_version": 3000,
  "whitelist": [
    { "imei": "000000000000000" },
    { "imei": "000000000000001" },
    { "imei": "000000000000002" }
  ]
}
""")

        dbo.releases.t.insert().execute(name='foxfood-whitelisted', product='b2g', data_version=1, data="""
{
    "name": "foxfood-whitelisted",
    "schema_version": 1,
    "extv": "2.5",
    "hashFunction": "sha512",
    "platforms": {
        "p": {
            "buildID": "25",
            "locales": {
                "l": {
                    "complete": {
                        "filesize": 22,
                        "from": "*",
                        "hashValue": "23",
                        "fileUrl": "http://a.com/secrets"
                    }
                }
            }
        }
    }
}
""")
        dbo.releases.t.insert().execute(name='foxfood-fallback', product='b2g', data_version=1, data="""
{
    "name": "foxfood-fallback",
    "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"
                    }
                }
            }
        }
    }
}
""")
        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="""
{
    "name": "superblob",
    "schema_version": 4000,
    "products": ["response-a"]
}
""")
        dbo.releases.t.insert().execute(name='gmp', product='gmp', data_version=1, data="""
{
    "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="""
{
    "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="""
{
    "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"
                    }
                }
            }
        }
    }
}
""")
コード例 #8
0
ファイル: test_client.py プロジェクト: rwood-moz/balrog
    def setUp(self):
        self.cef_fd, self.cef_file = mkstemp()
        app.config['DEBUG'] = True
        app.config['SPECIAL_FORCE_HOSTS'] = ('http://a.com',)
        app.config['WHITELISTED_DOMAINS'] = ('a.com', 'boring.com')
        dbo.setDb('sqlite:///:memory:')
        dbo.create()
        dbo.setDomainWhitelist(('a.com', 'boring.com'))
        self.client = app.test_client()
        self.view = ClientRequestView()
        auslib.log.cef_config = auslib.log.get_cef_config(self.cef_file)
        dbo.rules.t.insert().execute(backgroundRate=100, mapping='b', update_type='minor', product='b', data_version=1)
        dbo.releases.t.insert().execute(name='b', product='b', version='1.0', data_version=1, data="""
{
    "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(backgroundRate=100, mapping='c', update_type='minor', product='c',
                                     distribution='default', data_version=1)
        dbo.releases.t.insert().execute(name='c', product='c', version='10.0', data_version=1, data="""
{
    "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(backgroundRate=100, mapping='d', update_type='minor', product='d', data_version=1)
        dbo.releases.t.insert().execute(name='d', product='d', version='20.0', data_version=1, data="""
{
    "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(backgroundRate=100, mapping='e', update_type='minor', product='e', data_version=1)
        dbo.releases.t.insert().execute(name='e', product='e', version='22.0', data_version=1, data="""
{
    "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(backgroundRate=100, mapping='foxfood', update_type='minor', product='b2g', whitelist='b2g-whitelist', data_version=1)
        dbo.releases.t.insert().execute(name='b2g-whitelist', product='b2g', version='2.5', data_version=1, data="""
{
  "name": "b2g-whitelist",
  "schema_version": 3000,
  "whitelist": [
    { "imei": "000000000000000" },
    { "imei": "000000000000001" },
    { "imei": "000000000000002" }
  ]
}
""")

        dbo.releases.t.insert().execute(name='foxfood', product='b2g', version='2.5', data_version=1, data="""
{
    "name": "foxfood",
    "schema_version": 1,
    "extv": "2.5",
    "hashFunction": "sha512",
    "platforms": {
        "p": {
            "buildID": "25",
            "locales": {
                "l": {
                    "complete": {
                        "filesize": 22,
                        "from": "*",
                        "hashValue": "23",
                        "fileUrl": "http://a.com/y"
                    }
                }
            }
        }
    }
}
""")
コード例 #9
0
ファイル: base.py プロジェクト: EkkiD/balrog
    def setUp(self):
        app.config["SECRET_KEY"] = "abc123"
        app.config["DEBUG"] = True
        db.setDburi("sqlite:///:memory:")
        db.createTables()
        db.permissions.t.insert().execute(permission="admin", username="******", data_version=1)
        db.permissions.t.insert().execute(
            permission="/users/:id/permissions/:permission", username="******", data_version=1
        )
        db.permissions.t.insert().execute(
            permission="/releases/:name", username="******", options=json.dumps(dict(product="fake")), data_version=1
        )
        db.releases.t.insert().execute(
            name="a", product="a", version="a", data=json.dumps(dict(name="a")), data_version=1
        )
        db.releases.t.insert().execute(
            name="ab", product="a", version="a", data=json.dumps(dict(name="ab")), data_version=1
        )
        db.releases.t.insert().execute(
            name="b", product="b", version="b", data=json.dumps(dict(name="b")), data_version=1
        )
        db.releases.t.insert().execute(
            name="c", product="c", version="c", data=json.dumps(dict(name="c")), data_version=1
        )
        db.releases.t.insert().execute(
            name="d",
            product="d",
            version="d",
            data_version=1,
            data="""
{
    "name": "d",
    "platforms": {
        "p": {
            "locales": {
                "d": {
                    "complete": {
                        "filesize": 1234
                    }
                }
            }
        }
    }
}
""",
        )
        db.rules.t.insert().execute(
            id=1,
            priority=100,
            version="3.5",
            buildTarget="d",
            throttle=100,
            mapping="c",
            update_type="minor",
            data_version=1,
        )
        db.rules.t.insert().execute(
            id=2,
            priority=100,
            version="3.3",
            buildTarget="d",
            throttle=100,
            mapping="b",
            update_type="minor",
            data_version=1,
        )
        db.rules.t.insert().execute(
            id=3,
            priority=100,
            version="3.5",
            buildTarget="a",
            throttle=100,
            mapping="a",
            update_type="minor",
            data_version=1,
        )
        db.rules.t.insert().execute(
            id=4, priority=80, buildTarget="d", throttle=100, mapping="a", update_type="minor", data_version=1
        )
        db.rules.t.insert().execute(
            id=5,
            priority=80,
            buildTarget="d",
            version="3.3",
            throttle=0,
            mapping="c",
            update_type="minor",
            data_version=1,
        )
        self.client = app.test_client()
コード例 #10
0
ファイル: test_client.py プロジェクト: nthomas-mozilla/balrog
    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",
                "b2g",
                "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", "b2g")})
        self.client = app.test_client()
        self.view = ClientRequestView()
        dbo.rules.t.insert().execute(
            priority=90, backgroundRate=100, mapping="b", update_type="minor", product="b", data_version=1
        )
        dbo.releases.t.insert().execute(
            name="b",
            product="b",
            data_version=1,
            data="""
{
    "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",
            systemCapabilities="SSE",
            data_version=1,
        )
        dbo.releases.t.insert().execute(
            name="s",
            product="s",
            data_version=1,
            data="""
{
    "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="""
{
    "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="""
{
    "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="""
{
    "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="""
{
    "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="""
{
    "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=100,
            backgroundRate=100,
            mapping="foxfood-whitelisted",
            update_type="minor",
            product="b2g",
            whitelist="b2g-whitelist",
            data_version=1,
        )
        dbo.rules.t.insert().execute(
            priority=90,
            backgroundRate=100,
            mapping="foxfood-whitelisted",
            update_type="minor",
            product="b2g",
            channel="foxfood",
            whitelist="b2g-whitelist",
            data_version=1,
        )
        dbo.rules.t.insert().execute(
            priority=80,
            backgroundRate=100,
            mapping="foxfood-fallback",
            update_type="minor",
            product="b2g",
            data_version=1,
        )
        dbo.releases.t.insert().execute(
            name="b2g-whitelist",
            product="b2g",
            data_version=1,
            data="""
{
  "name": "b2g-whitelist",
  "schema_version": 3000,
  "whitelist": [
    { "imei": "000000000000000" },
    { "imei": "000000000000001" },
    { "imei": "000000000000002" }
  ]
}
""",
        )

        dbo.releases.t.insert().execute(
            name="foxfood-whitelisted",
            product="b2g",
            data_version=1,
            data="""
{
    "name": "foxfood-whitelisted",
    "schema_version": 1,
    "extv": "2.5",
    "hashFunction": "sha512",
    "platforms": {
        "p": {
            "buildID": "25",
            "locales": {
                "l": {
                    "complete": {
                        "filesize": 22,
                        "from": "*",
                        "hashValue": "23",
                        "fileUrl": "http://a.com/secrets"
                    }
                }
            }
        }
    }
}
""",
        )
        dbo.releases.t.insert().execute(
            name="foxfood-fallback",
            product="b2g",
            data_version=1,
            data="""
{
    "name": "foxfood-fallback",
    "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"
                    }
                }
            }
        }
    }
}
""",
        )
        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="""
{
    "name": "superblob",
    "schema_version": 4000,
    "products": ["response-a"]
}
""",
        )
        dbo.releases.t.insert().execute(
            name="gmp",
            product="gmp",
            data_version=1,
            data="""
{
    "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="""
{
    "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="""
{
    "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="""
{
    "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="""
{
    "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="""
{
    "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="""
{
    "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="""
{
    "name": "superblobaddon",
    "schema_version": 4000,
    "revision": 123,
    "blobs": ["responseblob-a"]
}
""",
        )
        dbo.releases.t.insert().execute(
            name="superblobaddon-with-multiple-response-blob",
            product="superblobaddon-with-multiple-response-blob",
            data_version=1,
            data="""
{
    "name": "superblobaddon",
    "schema_version": 4000,
    "revision": 124,
    "blobs": ["responseblob-a", "responseblob-b"]
}
""",
        )
        dbo.releases.t.insert().execute(
            name="responseblob-a",
            product="responseblob-a",
            data_version=1,
            data="""
{
    "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="""
{
    "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"

                }
            }
        }
    }
}
""",
        )
コード例 #11
0
    def setUp(self):
        self.cef_fd, self.cef_file = mkstemp()
        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', 'boring.com')
        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', 'boring.com'))
        self.client = app.test_client()
        self.view = ClientRequestView()
        auslib.log.cef_config = auslib.log.get_cef_config(self.cef_file)
        dbo.rules.t.insert().execute(backgroundRate=100,
                                     mapping='b',
                                     update_type='minor',
                                     product='b',
                                     data_version=1)
        dbo.releases.t.insert().execute(name='b',
                                        product='b',
                                        data_version=1,
                                        data="""
{
    "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(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="""
{
    "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(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="""
{
    "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(backgroundRate=100,
                                     mapping='e',
                                     update_type='minor',
                                     product='e',
                                     data_version=1)
        dbo.releases.t.insert().execute(name='e',
                                        product='e',
                                        data_version=1,
                                        data="""
{
    "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=100,
                                     backgroundRate=100,
                                     mapping='foxfood-whitelisted',
                                     update_type='minor',
                                     product='b2g',
                                     whitelist='b2g-whitelist',
                                     data_version=1)
        dbo.rules.t.insert().execute(priority=90,
                                     backgroundRate=100,
                                     mapping='foxfood-whitelisted',
                                     update_type='minor',
                                     product='b2g',
                                     channel="foxfood",
                                     whitelist='b2g-whitelist',
                                     data_version=1)
        dbo.rules.t.insert().execute(priority=80,
                                     backgroundRate=100,
                                     mapping='foxfood-fallback',
                                     update_type='minor',
                                     product='b2g',
                                     data_version=1)
        dbo.releases.t.insert().execute(name='b2g-whitelist',
                                        product='b2g',
                                        data_version=1,
                                        data="""
{
  "name": "b2g-whitelist",
  "schema_version": 3000,
  "whitelist": [
    { "imei": "000000000000000" },
    { "imei": "000000000000001" },
    { "imei": "000000000000002" }
  ]
}
""")

        dbo.releases.t.insert().execute(name='foxfood-whitelisted',
                                        product='b2g',
                                        data_version=1,
                                        data="""
{
    "name": "foxfood-whitelisted",
    "schema_version": 1,
    "extv": "2.5",
    "hashFunction": "sha512",
    "platforms": {
        "p": {
            "buildID": "25",
            "locales": {
                "l": {
                    "complete": {
                        "filesize": 22,
                        "from": "*",
                        "hashValue": "23",
                        "fileUrl": "http://a.com/secrets"
                    }
                }
            }
        }
    }
}
""")
        dbo.releases.t.insert().execute(name='foxfood-fallback',
                                        product='b2g',
                                        data_version=1,
                                        data="""
{
    "name": "foxfood-fallback",
    "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"
                    }
                }
            }
        }
    }
}
""")
コード例 #12
0
ファイル: test_client.py プロジェクト: escapewindow/balrog
    def setUp(self):
        self.cef_fd, self.cef_file = mkstemp()
        app.config["DEBUG"] = True
        app.config["SPECIAL_FORCE_HOSTS"] = ("http://a.com",)
        app.config["WHITELISTED_DOMAINS"] = ("a.com", "boring.com")
        dbo.setDb("sqlite:///:memory:")
        dbo.create()
        dbo.setDomainWhitelist(("a.com", "boring.com"))
        self.client = app.test_client()
        self.view = ClientRequestView()
        auslib.log.cef_config = auslib.log.get_cef_config(self.cef_file)
        dbo.rules.t.insert().execute(backgroundRate=100, mapping="b", update_type="minor", product="b", data_version=1)
        dbo.releases.t.insert().execute(
            name="b",
            product="b",
            version="1.0",
            data_version=1,
            data="""
{
    "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(
            backgroundRate=100, mapping="c", update_type="minor", product="c", distribution="default", data_version=1
        )
        dbo.releases.t.insert().execute(
            name="c",
            product="c",
            version="10.0",
            data_version=1,
            data="""
{
    "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(backgroundRate=100, mapping="d", update_type="minor", product="d", data_version=1)
        dbo.releases.t.insert().execute(
            name="d",
            product="d",
            version="20.0",
            data_version=1,
            data="""
{
    "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(backgroundRate=100, mapping="e", update_type="minor", product="e", data_version=1)
        dbo.releases.t.insert().execute(
            name="e",
            product="e",
            version="22.0",
            data_version=1,
            data="""
{
    "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=100,
            backgroundRate=100,
            mapping="foxfood-whitelisted",
            update_type="minor",
            product="b2g",
            whitelist="b2g-whitelist",
            data_version=1,
        )
        dbo.rules.t.insert().execute(
            priority=90,
            backgroundRate=100,
            mapping="foxfood-whitelisted",
            update_type="minor",
            product="b2g",
            channel="foxfood",
            whitelist="b2g-whitelist",
            data_version=1,
        )
        dbo.rules.t.insert().execute(
            priority=80,
            backgroundRate=100,
            mapping="foxfood-fallback",
            update_type="minor",
            product="b2g",
            data_version=1,
        )
        dbo.releases.t.insert().execute(
            name="b2g-whitelist",
            product="b2g",
            version="2.5",
            data_version=1,
            data="""
{
  "name": "b2g-whitelist",
  "schema_version": 3000,
  "whitelist": [
    { "imei": "000000000000000" },
    { "imei": "000000000000001" },
    { "imei": "000000000000002" }
  ]
}
""",
        )

        dbo.releases.t.insert().execute(
            name="foxfood-whitelisted",
            product="b2g",
            version="2.5",
            data_version=1,
            data="""
{
    "name": "foxfood-whitelisted",
    "schema_version": 1,
    "extv": "2.5",
    "hashFunction": "sha512",
    "platforms": {
        "p": {
            "buildID": "25",
            "locales": {
                "l": {
                    "complete": {
                        "filesize": 22,
                        "from": "*",
                        "hashValue": "23",
                        "fileUrl": "http://a.com/secrets"
                    }
                }
            }
        }
    }
}
""",
        )
        dbo.releases.t.insert().execute(
            name="foxfood-fallback",
            product="b2g",
            version="2.5",
            data_version=1,
            data="""
{
    "name": "foxfood-fallback",
    "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"
                    }
                }
            }
        }
    }
}
""",
        )