Skip to content

Commit

Permalink
Merge pull request openwisp#61 from shashwat1002/issue#34_autgen_cert
Browse files Browse the repository at this point in the history
[x509] Fix certificates without organization assigned openwisp#34
  • Loading branch information
nemesifier committed Nov 19, 2018
2 parents 36663df + 9ac2ea2 commit 75077b0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ install:
- pipenv install $DJANGO
# fix issues with travis
- pipenv install --skip-lock "attrs>=17.4.0"
- pipenv install --skip-lock "six>=1.11.0"
- pipenv install --skip-lock "six"
# TODO: temporary, remove when django-netjsonconfig 0.9.0 is released
- if [[ $TRAVIS_PYTHON_VERSION == "2.7" ]]; then pipenv install git+git://github.com/tinio/pysqlite.git@extension-enabled#egg=pysqlite; fi
- pipenv run pip install https://github.com/openwisp/django-x509/tarball/master
Expand Down
2 changes: 1 addition & 1 deletion openwisp_controller/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _auto_create_cert_extra(self, cert):
"""
sets the organization on the created client certificate
"""
cert.organization = self.vpn.organization
cert.organization = self.config.device.organization
return cert


Expand Down
15 changes: 15 additions & 0 deletions openwisp_controller/config/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,18 @@ def test_auto_client_template_default(self):
vpn=vpn,
config={})
self._create_config(organization=org)

def test_auto_generated_certificate_for_organization(self):
organization = self._create_org()
vpn = self._create_vpn()
template = self._create_template(type='vpn', auto_cert=True, vpn=vpn)
corresponding_device = self._create_device(organization=organization,)
config = self._create_config(
device=corresponding_device,
organization=corresponding_device.organization
)
config.templates.add(template)
vpn_clients = config.vpnclient_set.all()
for vpn_client in vpn_clients:
self.assertIsNotNone(vpn_client.cert.organization)
self.assertEqual(vpn_client.cert.organization, config.device.organization)

0 comments on commit 75077b0

Please sign in to comment.