Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
fix(proctype): Change the regex used for validating proctypes
Browse files Browse the repository at this point in the history
  • Loading branch information
kmala committed Nov 8, 2016
1 parent 7e0692a commit f3daff7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rootfs/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

# proc type name is alphanumeric
# https://docs-v2.readthedocs.io/en/latest/using-workflow/process-types-and-the-procfile/#declaring-process-types
PROCTYPE_MATCH = re.compile(r'^(?P<type>[a-z0-9]+)$')
PROCTYPE_MATCH = re.compile(r'^(?P<type>[a-zA-Z0-9]+(\-[a-zA-Z0-9]+)*)$')
MEMLIMIT_MATCH = re.compile(
r'^(?P<mem>(([0-9]+(MB|KB|GB|[BKMG])|0)(/([0-9]+(MB|KB|GB|[BKMG])))?))$', re.IGNORECASE)
CPUSHARE_MATCH = re.compile(
Expand Down
47 changes: 47 additions & 0 deletions rootfs/api/tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,41 @@ def test_build_validate_procfile(self, mock_requests):
}
response = self.client.post(url, body)
self.assertEqual(response.status_code, 400, response.data)

url = "/v2/apps/{app_id}/builds".format(**locals())
body = {
'image': 'autotest/example',
'sha': 'a'*40,
'procfile': {
'web': 'node server.js',
'-': 'node worker.js'
}
}
response = self.client.post(url, body)
self.assertEqual(response.status_code, 400, response.data)

url = "/v2/apps/{app_id}/builds".format(**locals())
body = {
'image': 'autotest/example',
'sha': 'a'*40,
'procfile': {
'web': 'node server.js',
'worker-': 'node worker.js'
}
}
response = self.client.post(url, body)
self.assertEqual(response.status_code, 400, response.data)
url = "/v2/apps/{app_id}/builds".format(**locals())
body = {
'image': 'autotest/example',
'sha': 'a'*40,
'procfile': {
'web': 'node server.js',
'-worker': 'node worker.js'
}
}
response = self.client.post(url, body)
self.assertEqual(response.status_code, 400, response.data)
# deploy app with empty command
url = "/v2/apps/{app_id}/builds".format(**locals())
body = {
Expand All @@ -719,3 +754,15 @@ def test_build_validate_procfile(self, mock_requests):
}
response = self.client.post(url, body)
self.assertEqual(response.status_code, 400, response.data)

url = "/v2/apps/{app_id}/builds".format(**locals())
body = {
'image': 'autotest/example',
'sha': 'a'*40,
'procfile': {
'web': 'node server.js',
'Worker-test1': 'node worker.js'
}
}
response = self.client.post(url, body)
self.assertEqual(response.status_code, 201, response.data)

0 comments on commit f3daff7

Please sign in to comment.