Skip to content

Commit 836c285

Browse files
authored
Merge pull request #1132 from kmala/proctype
fix(proctype): Change the regex used for validating proctypes
2 parents 7e0692a + f3daff7 commit 836c285

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

rootfs/api/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
# proc type name is alphanumeric
2020
# https://docs-v2.readthedocs.io/en/latest/using-workflow/process-types-and-the-procfile/#declaring-process-types
21-
PROCTYPE_MATCH = re.compile(r'^(?P<type>[a-z0-9]+)$')
21+
PROCTYPE_MATCH = re.compile(r'^(?P<type>[a-zA-Z0-9]+(\-[a-zA-Z0-9]+)*)$')
2222
MEMLIMIT_MATCH = re.compile(
2323
r'^(?P<mem>(([0-9]+(MB|KB|GB|[BKMG])|0)(/([0-9]+(MB|KB|GB|[BKMG])))?))$', re.IGNORECASE)
2424
CPUSHARE_MATCH = re.compile(

rootfs/api/tests/test_build.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,41 @@ def test_build_validate_procfile(self, mock_requests):
707707
}
708708
response = self.client.post(url, body)
709709
self.assertEqual(response.status_code, 400, response.data)
710+
711+
url = "/v2/apps/{app_id}/builds".format(**locals())
712+
body = {
713+
'image': 'autotest/example',
714+
'sha': 'a'*40,
715+
'procfile': {
716+
'web': 'node server.js',
717+
'-': 'node worker.js'
718+
}
719+
}
720+
response = self.client.post(url, body)
721+
self.assertEqual(response.status_code, 400, response.data)
722+
723+
url = "/v2/apps/{app_id}/builds".format(**locals())
724+
body = {
725+
'image': 'autotest/example',
726+
'sha': 'a'*40,
727+
'procfile': {
728+
'web': 'node server.js',
729+
'worker-': 'node worker.js'
730+
}
731+
}
732+
response = self.client.post(url, body)
733+
self.assertEqual(response.status_code, 400, response.data)
734+
url = "/v2/apps/{app_id}/builds".format(**locals())
735+
body = {
736+
'image': 'autotest/example',
737+
'sha': 'a'*40,
738+
'procfile': {
739+
'web': 'node server.js',
740+
'-worker': 'node worker.js'
741+
}
742+
}
743+
response = self.client.post(url, body)
744+
self.assertEqual(response.status_code, 400, response.data)
710745
# deploy app with empty command
711746
url = "/v2/apps/{app_id}/builds".format(**locals())
712747
body = {
@@ -719,3 +754,15 @@ def test_build_validate_procfile(self, mock_requests):
719754
}
720755
response = self.client.post(url, body)
721756
self.assertEqual(response.status_code, 400, response.data)
757+
758+
url = "/v2/apps/{app_id}/builds".format(**locals())
759+
body = {
760+
'image': 'autotest/example',
761+
'sha': 'a'*40,
762+
'procfile': {
763+
'web': 'node server.js',
764+
'Worker-test1': 'node worker.js'
765+
}
766+
}
767+
response = self.client.post(url, body)
768+
self.assertEqual(response.status_code, 201, response.data)

0 commit comments

Comments
 (0)