Skip to content

Commit 1759f93

Browse files
author
Matt Tucker
committed
Merge branch 'master' of github.com:deis/controller into virtualenv-links
2 parents 1c57745 + 56118da commit 1759f93

5 files changed

Lines changed: 35 additions & 14 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ commit-hook:
4242
full-clean: check-docker
4343
docker images -q $(IMAGE_PREFIX)$(COMPONENT) | xargs docker rmi -f
4444

45-
postgres:
45+
postgres: check-docker
4646
docker start postgres || docker run --restart="always" -d -p 5432:5432 --name postgres postgres:9.3
4747
docker exec postgres createdb -U postgres deis 2>/dev/null || true
4848
@echo "To use postgres for local development:"

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,27 @@ helmc install workflow-dev
5050

5151
### Postgresql
5252

53-
Postgresql can be installed via `homebrew`:
54-
53+
The application and tests use PostgreSQL. To start a local instance via Docker, run `make postgres` and set the following in your shell:
5554
```
56-
brew install postgresql
55+
export PGHOST=`docker-machine ip $(docker-machine active) 2>/dev/null || echo 127.0.0.1`
56+
export PGPORT=5432
57+
export PGUSER=postgres
5758
```
5859

59-
Or via your package manager. For example, on Debian Jessie:
60+
### Python
61+
62+
Python 3.5 is a minimum requirement and can be installed via `pyenv`:
6063

6164
```
62-
apt-get install postgresql libpq-dev
65+
brew install pyenv
6366
```
6467

65-
### Python
66-
67-
Python 3.5 is a minimum requirement and can be installed via `homebrew`:
68-
68+
- After installing, ensure [`eval "$(pyenv init -)"` is added to your shell startup.](https://github.com/yyuu/pyenv/#homebrew-on-mac-os-x)
69+
- Install and use Python 3.5:
6970
```
70-
brew install python3
71+
pyenv install 3.5.0
72+
# if you have build issues, ensure Xcode CLI tools are installed:https://github.com/yyuu/pyenv/issues/451#issuecomment-151336786
73+
python local 3.5.0 # use Python 3.5.0 in your current directory
7174
```
7275

7376
Or via your package manager. For example, on Debian Jessie:

rootfs/api/permissions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from rest_framework import exceptions
33
from rest_framework import permissions
44
from django.conf import settings
5-
from django.contrib.auth.models import AnonymousUser
5+
from django.contrib.auth.models import AnonymousUser, User
66

77
from api import models
88

@@ -109,6 +109,8 @@ def has_permission(self, request, view):
109109
if settings.REGISTRATION_MODE == 'enabled':
110110
return True
111111
elif settings.REGISTRATION_MODE == 'admin_only':
112+
if not User.objects.filter(is_superuser=True).exists():
113+
return True
112114
return request.user.is_superuser
113115
else:
114116
raise Exception("{} is not a valid registation mode"

rootfs/api/tests/test_perm.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.contrib.auth.models import User
22
from rest_framework.authtoken.models import Token
3+
from django.test.utils import override_settings
34
from api.tests import DeisTestCase
45

56

@@ -32,6 +33,21 @@ def test_first_signup(self):
3233
self.assertEqual(response.status_code, 201, response.data)
3334
self.assertFalse(response.data['is_superuser'])
3435

36+
@override_settings(REGISTRATION_MODE="admin_only")
37+
def test_first_signup_admin_only(self):
38+
# register a first user
39+
username, password = 'firstuser', 'password'
40+
email = 'autotest@deis.io'
41+
submit = {
42+
'username': username,
43+
'password': password,
44+
'email': email,
45+
}
46+
url = '/v2/auth/register'
47+
response = self.client.post(url, submit)
48+
self.assertEqual(response.status_code, 201, response.data)
49+
self.assertTrue(response.data['is_superuser'])
50+
3551
def test_list(self):
3652
submit = {
3753
'username': 'firstuser',

rootfs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ Django==1.10.2
44
django-cors-middleware==1.3.1
55
django-guardian==1.4.6
66
djangorestframework==3.4.7
7-
docker-py==1.10.3
7+
docker-py==1.10.4
88
gunicorn==19.6.0
99
jmespath==0.9.0
1010
jsonfield==1.0.3
1111
morph==0.1.2
1212
ndg-httpsclient==0.4.2
1313
psycopg2==2.6.2
14-
pyOpenSSL==16.1.0
14+
pyOpenSSL==16.2.0
1515
pytz==2016.7
1616
requests==2.11.1
1717
requests-toolbelt==0.7.0

0 commit comments

Comments
 (0)