diff options
author | Tomas Sedovic <tomas@sedovic.cz> | 2013-08-02 07:32:17 -0700 |
---|---|---|
committer | Tomas Sedovic <tomas@sedovic.cz> | 2013-08-02 07:32:17 -0700 |
commit | 57054ca4e1bed439225df4727e86f024526abe8e (patch) | |
tree | dcb7b1b098b865f6e3a713aa3b26395025d82359 | |
parent | b4118e149bb9c5f7474d8953c1858674215758cc (diff) | |
parent | 652277911c0f04a8475f4da631f52301df938133 (diff) | |
download | tuskar-ui-57054ca4e1bed439225df4727e86f024526abe8e.tar.gz |
Merge pull request #5 from tuskar/auth-fix
Auth fix
3 files changed, 57 insertions, 17 deletions
diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py b/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py index ac325d43..c8876374 100644 --- a/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py +++ b/openstack_dashboard/dashboards/project/images_and_snapshots/images/forms.py @@ -44,13 +44,30 @@ class CreateImageForm(forms.SelfHandlingForm): description = forms.CharField(widget=forms.widgets.Textarea(), label=_("Description"), required=False) + + source_type = forms.ChoiceField( + label=_('Image Source'), + choices=[('url', _('Image Location')), + ('file', _('Image File'))], + widget=forms.Select(attrs={ + 'class': 'switchable', + 'data-slug': 'source'})) + copy_from = forms.CharField(max_length="255", label=_("Image Location"), help_text=_("An external (HTTP) URL to load " "the image from."), + widget=forms.TextInput(attrs={ + 'class': 'switched', + 'data-switch-on': 'source', + 'data-source-url': _('Image Location')}), required=False) image_file = forms.FileField(label=_("Image File"), help_text=("A local image to upload."), + widget=forms.FileInput(attrs={ + 'class': 'switched', + 'data-switch-on': 'source', + 'data-source-file': _('Image File')}), required=False) disk_format = forms.ChoiceField(label=_('Format'), required=True, diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py b/openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py index b4d7626f..585804cb 100644 --- a/openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py +++ b/openstack_dashboard/dashboards/project/images_and_snapshots/images/tests.py @@ -50,6 +50,7 @@ class CreateImageFormTests(test.TestCase): """ post = { 'name': u'Ubuntu 11.10', + 'source_type': u'file', 'description': u'Login with admin/admin', 'disk_format': u'qcow2', 'minimum_disk': 15, @@ -82,6 +83,7 @@ class ImageViewTests(test.TestCase): data = { 'name': u'Ubuntu 11.10', 'description': u'Login with admin/admin', + 'source_type': u'url', 'copy_from': u'http://cloud-images.ubuntu.com/releases/' u'oneiric/release/ubuntu-11.10-server-cloudimg' u'-amd64-disk1.img', @@ -121,6 +123,7 @@ class ImageViewTests(test.TestCase): data = { 'name': u'Test Image', 'description': u'Login with admin/admin', + 'source_type': u'file', 'image_file': temp_file, 'disk_format': u'qcow2', 'minimum_disk': 15, diff --git a/openstack_dashboard/test/test_data/keystone_data.py b/openstack_dashboard/test/test_data/keystone_data.py index b9d41920..e92131b1 100644 --- a/openstack_dashboard/test/test_data/keystone_data.py +++ b/openstack_dashboard/test/test_data/keystone_data.py @@ -17,14 +17,15 @@ from datetime import timedelta from django.conf import settings from django.utils import datetime_safe +from keystoneclient.access import AccessInfo from keystoneclient.v2_0 import ec2 from keystoneclient.v2_0 import roles from keystoneclient.v2_0 import tenants -from keystoneclient.v2_0 import tokens from keystoneclient.v2_0 import users from keystoneclient.v3 import domains from keystoneclient.v3 import groups +from openstack_auth.user import Token from openstack_dashboard.test.test_data.utils import TestDataContainer @@ -223,22 +224,41 @@ def data(TEST): tomorrow = datetime_safe.datetime.now() + timedelta(days=1) expiration = datetime_safe.datetime.isoformat(tomorrow) - scoped_token = tokens.Token(tokens.TokenManager, - dict(token={"id": "test_token_id", - "expires": expiration, - "tenant": tenant_dict, - "tenants": [tenant_dict]}, - user={"id": "test_user_id", - "name": "test_user", - "roles": [member_role_dict]}, - serviceCatalog=TEST.service_catalog)) - unscoped_token = tokens.Token(tokens.TokenManager, - dict(token={"id": "test_token_id", - "expires": expiration}, - user={"id": "test_user_id", - "name": "test_user", - "roles": [member_role_dict]}, - serviceCatalog=TEST.service_catalog)) + scoped_token_dict = { + 'access': { + 'token': { + 'id': "test_token_id", + 'expires': expiration, + 'tenant': tenant_dict, + 'tenants': [tenant_dict]}, + 'user': { + 'id': "test_user_id", + 'name': "test_user", + 'roles': [member_role_dict]}, + 'serviceCatalog': TEST.service_catalog + } + } + + scoped_access_info = AccessInfo.factory(resp=None, + body=scoped_token_dict) + + unscoped_token_dict = { + 'access': { + 'token': { + 'id': "test_token_id", + 'expires': expiration}, + 'user': { + 'id': "test_user_id", + 'name': "test_user", + 'roles': [member_role_dict]}, + 'serviceCatalog': TEST.service_catalog + } + } + unscoped_access_info = AccessInfo.factory(resp=None, + body=unscoped_token_dict) + + scoped_token = Token(scoped_access_info) + unscoped_token = Token(unscoped_access_info) TEST.tokens.add(scoped_token, unscoped_token) TEST.token = scoped_token # your "current" token. TEST.tokens.scoped_token = scoped_token |