Skip to content

Commit

Permalink
bug 1026827: Support /update/1/ requests. r=nthomas
Browse files Browse the repository at this point in the history
  • Loading branch information
bhearsum committed Feb 12, 2015
1 parent 7f6bacd commit 663808f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
33 changes: 24 additions & 9 deletions auslib/test/web/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,8 @@ def testDontDecreaseVersion(self):
self.assertEqual(ret.mimetype, 'text/xml')
self.assertEqual(minidom.parseString(ret.data).getElementsByTagName('updates')[0].firstChild.nodeValue, '\n')

def testVersion3Get(self):
ret = self.client.get('/update/3/a/1.0/1/a/a/a/a/a/a/update.xml')
self.assertEqual(ret.status_code, 200)
self.assertEqual(ret.mimetype, 'text/xml')
# An empty update contains an <updates> tag with a newline, which is what we're expecting here
self.assertEqual(minidom.parseString(ret.data).getElementsByTagName('updates')[0].firstChild.nodeValue, '\n')

def testVersion3GetWithUpdate(self):
ret = self.client.get('/update/3/b/1.0/1/p/l/a/a/a/a/update.xml')
def testVersion1Get(self):
ret = self.client.get("/update/1/b/1.0/1/p/l/a/update.xml")
self.assertEqual(ret.status_code, 200)
self.assertEqual(ret.mimetype, 'text/xml')
# We need to load and re-xmlify these to make sure we don't get failures due to whitespace differences.
Expand Down Expand Up @@ -219,6 +212,28 @@ def testVersion2GetIgnoresRuleWithDistribution(self):
# We need to load and re-xmlify these to make sure we don't get failures due to whitespace differences.
self.assertEqual(minidom.parseString(ret.data).getElementsByTagName('updates')[0].firstChild.nodeValue, '\n')

def testVersion3Get(self):
ret = self.client.get('/update/3/a/1.0/1/a/a/a/a/a/a/update.xml')
self.assertEqual(ret.status_code, 200)
self.assertEqual(ret.mimetype, 'text/xml')
# An empty update contains an <updates> tag with a newline, which is what we're expecting here
self.assertEqual(minidom.parseString(ret.data).getElementsByTagName('updates')[0].firstChild.nodeValue, '\n')

def testVersion3GetWithUpdate(self):
ret = self.client.get('/update/3/b/1.0/1/p/l/a/a/a/a/update.xml')
self.assertEqual(ret.status_code, 200)
self.assertEqual(ret.mimetype, 'text/xml')
# We need to load and re-xmlify these to make sure we don't get failures due to whitespace differences.
returned = minidom.parseString(ret.data)
expected = minidom.parseString("""<?xml version="1.0"?>
<updates>
<update type="minor" version="1.0" extensionVersion="1.0" buildID="2">
<patch type="complete" URL="http://a.com/z" hashFunction="sha512" hashValue="4" size="3"/>
</update>
</updates>
""")
self.assertEqual(returned.toxml(), expected.toxml())

def testVersion4Get(self):
ret = self.client.get('/update/4/b/1.0/1/p/l/a/a/a/a/1/update.xml')
self.assertEqual(ret.status_code, 200)
Expand Down
9 changes: 9 additions & 0 deletions auslib/web/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ def generic(error):
def robots():
return send_from_directory(app.static_folder, "robots.txt")

app.add_url_rule(
"/update/1/<product>/<version>/<buildID>/<buildTarget>/<locale>/<channel>/update.xml",
view_func=ClientRequestView.as_view("clientrequest1"),
# Underlying code depends on osVersion being set. Since this route only
# exists to support ancient queries, and all newer versions have osVersion
# in them it's easier to set this here than make the all of the underlying
# code support queries without it.
defaults={"queryVersion": 2, "osVersion": ""},
)
app.add_url_rule(
'/update/2/<product>/<version>/<buildID>/<buildTarget>/<locale>/<channel>/<osVersion>/update.xml',
view_func=ClientRequestView.as_view('clientrequest2'),
Expand Down

0 comments on commit 663808f

Please sign in to comment.