Skip to content

Commit

Permalink
change oauth.consumer description into nullable
Browse files Browse the repository at this point in the history
Change-Id: I158e916f1f422882b83f648d7720f8f87a4c5813
Fixes: Bug #1215482
  • Loading branch information
gongysh committed Aug 23, 2013
1 parent 4dbda64 commit 42b107e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion keystone/contrib/oauth1/backends/sql.py
Expand Up @@ -29,7 +29,7 @@ class Consumer(sql.ModelBase, sql.DictBase):
__tablename__ = 'consumer'
attributes = ['id', 'description', 'secret']
id = sql.Column(sql.String(64), primary_key=True, nullable=False)
description = sql.Column(sql.String(64), nullable=False)
description = sql.Column(sql.String(64), nullable=True)
secret = sql.Column(sql.String(64), nullable=False)
extra = sql.Column(sql.JsonBlob(), nullable=False)

Expand Down
@@ -0,0 +1,31 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright 2013 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import sqlalchemy as sql


def upgrade(migrate_engine):
meta = sql.MetaData()
meta.bind = migrate_engine
user_table = sql.Table('consumer', meta, autoload=True)
user_table.c.description.alter(nullable=True)


def downgrade(migrate_engine):
meta = sql.MetaData()
meta.bind = migrate_engine
user_table = sql.Table('consumer', meta, autoload=True)
user_table.c.description.alter(nullable=False)
20 changes: 16 additions & 4 deletions keystone/tests/test_v3_oauth1.py
Expand Up @@ -121,18 +121,30 @@ def _authorize_request_token(self, request_id):

class ConsumerCRUDTests(OAuth1Tests):

def test_consumer_create(self):
description = uuid.uuid4().hex
ref = {'description': description}
def _consumer_create(self, description=None, description_flag=True):
if description_flag:
ref = {'description': description}
else:
ref = {}
resp = self.post(
'/OS-OAUTH1/consumers',
body={'consumer': ref})
consumer = resp.result.get('consumer')
consumer_id = consumer.get('id')
self.assertEqual(consumer.get('description'), description)
self.assertEqual(consumer['description'], description)
self.assertIsNotNone(consumer_id)
self.assertIsNotNone(consumer.get('secret'))

def test_consumer_create(self):
description = uuid.uuid4().hex
self._consumer_create(description=description)

def test_consumer_create_none_desc_1(self):
self._consumer_create()

def test_consumer_create_none_desc_2(self):
self._consumer_create(description_flag=False)

def test_consumer_delete(self):
consumer = self._create_single_consumer()
consumer_id = consumer.get('id')
Expand Down

0 comments on commit 42b107e

Please sign in to comment.