Upgrade database definition
Project: http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/commit/8f36cd1b Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/tree/8f36cd1b Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/diff/8f36cd1b Branch: refs/heads/master Commit: 8f36cd1b5696dab1b91842e1ad21ebf0af5bd2f6 Parents: 4219ecc Author: BroganD1993 <darrenbro...@hotmail.com> Authored: Sun Jul 27 21:34:01 2014 +0100 Committer: BroganD1993 <darrenbro...@hotmail.com> Committed: Sun Jul 27 21:34:01 2014 +0100 ---------------------------------------------------------------------- gstack/configure.py | 4 ++-- gstack/oauth2provider.py | 1 + migrations/versions/25c3e5241cd0_.py | 35 +++++++++++++++++++++++++++++++ migrations/versions/76bb287a37d_.py | 24 ++++++++++----------- pylint.rc | 2 +- pyoauth2/tests/test_integration.py | 5 ++--- 6 files changed, 53 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/blob/8f36cd1b/gstack/configure.py ---------------------------------------------------------------------- diff --git a/gstack/configure.py b/gstack/configure.py index f528122..2bcf4bb 100644 --- a/gstack/configure.py +++ b/gstack/configure.py @@ -28,7 +28,7 @@ from alembic.config import Config as AlembicConfig def main(): config_folder = _create_config_folder() _create_config_file(config_folder) - _create_database() + _upgrade_database() def _create_config_folder(): @@ -113,7 +113,7 @@ def _read_in_config_attribute_or_use_default(message, default): return attribute -def _create_database(): +def _upgrade_database(): directory = os.path.join(os.path.dirname(__file__), '../migrations') database_config = AlembicConfig(os.path.join( directory, http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/blob/8f36cd1b/gstack/oauth2provider.py ---------------------------------------------------------------------- diff --git a/gstack/oauth2provider.py b/gstack/oauth2provider.py index 0c4a980..8eb166f 100644 --- a/gstack/oauth2provider.py +++ b/gstack/oauth2provider.py @@ -148,6 +148,7 @@ class CloudstackResourceProvider(ResourceProvider): return request.headers.get('Authorization') def validate_access_token(self, access_token, authorization): + print 'pp' found_access_token = AccessToken.query.get(access_token) if found_access_token is not None and found_access_token.data != 'false': access_token_data = json.loads(found_access_token.data) http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/blob/8f36cd1b/migrations/versions/25c3e5241cd0_.py ---------------------------------------------------------------------- diff --git a/migrations/versions/25c3e5241cd0_.py b/migrations/versions/25c3e5241cd0_.py new file mode 100644 index 0000000..b330147 --- /dev/null +++ b/migrations/versions/25c3e5241cd0_.py @@ -0,0 +1,35 @@ +"""empty message + +Revision ID: 25c3e5241cd0 +Revises: 76bb287a37d +Create Date: 2014-07-27 16:19:12.634404 + +""" + +# revision identifiers, used by Alembic. +revision = '25c3e5241cd0' +down_revision = '76bb287a37d' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('accesstoken', + sa.Column( + 'id_token', + sa.String(length=1000), + nullable=True + ) + ) + + op.add_column('refreshtoken', + sa.Column( + 'id_token', + sa.String(length=1000), + nullable=True + ) + ) + +def downgrade(): + pass http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/blob/8f36cd1b/migrations/versions/76bb287a37d_.py ---------------------------------------------------------------------- diff --git a/migrations/versions/76bb287a37d_.py b/migrations/versions/76bb287a37d_.py index 4353642..efc9887 100644 --- a/migrations/versions/76bb287a37d_.py +++ b/migrations/versions/76bb287a37d_.py @@ -16,7 +16,10 @@ import sqlalchemy as sa def upgrade(): op.create_table('accesstoken', - sa.Column('access_token', sa.String(length=255), nullable=False), + sa.Column( + 'access_token', + sa.String(length=255), + nullable=False), sa.Column( 'client_id', sa.String(length=255), @@ -26,10 +29,6 @@ def upgrade(): sa.String(length=10), nullable=True), sa.Column( - 'id_token', - sa.String(length=1000), - nullable=True), - sa.Column( 'data', sa.String(length=500), nullable=True), @@ -37,7 +36,9 @@ def upgrade(): sa.UniqueConstraint('client_id') ) op.create_table('client', - sa.Column('client_id', sa.String(length=255), nullable=False), + sa.Column('client_id', + sa.String(length=255), + nullable=False), sa.Column( 'client_secret', sa.String(length=255), @@ -46,14 +47,13 @@ def upgrade(): sa.UniqueConstraint('client_secret') ) op.create_table('refreshtoken', - sa.Column('refresh_token', sa.String(length=255), nullable=False), sa.Column( - 'client_id', + 'refresh_token', sa.String(length=255), - nullable=True), + nullable=False), sa.Column( - 'id_token', - sa.String(length=1000), + 'client_id', + sa.String(length=255), nullable=True), sa.Column( 'data', @@ -65,4 +65,4 @@ def upgrade(): def downgrade(): - pass + pass \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/blob/8f36cd1b/pylint.rc ---------------------------------------------------------------------- diff --git a/pylint.rc b/pylint.rc index 6173b69..baada8d 100644 --- a/pylint.rc +++ b/pylint.rc @@ -214,7 +214,7 @@ int-import-graph= [DESIGN] # Maximum number of arguments for function / method -max-args=8 +max-args=10 # Argument names that match this expression will be ignored. Default to name # with leading underscore http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/blob/8f36cd1b/pyoauth2/tests/test_integration.py ---------------------------------------------------------------------- diff --git a/pyoauth2/tests/test_integration.py b/pyoauth2/tests/test_integration.py index 8b7350e..e164304 100644 --- a/pyoauth2/tests/test_integration.py +++ b/pyoauth2/tests/test_integration.py @@ -57,7 +57,7 @@ class MockAuthorizationProvider(AuthorizationProvider): def persist_token_information(self, client_id, scope, access_token, token_type, expires_in, refresh_token, - data): + id_token, data): pass def discard_authorization_code(self, client_id, code): @@ -105,6 +105,5 @@ class IntegrationTest(unittest.TestCase): scope='example') self.assertEquals(40, len(data['access_token'])) - self.assertEquals(40, len(data['refresh_token'])) self.assertEquals('Bearer', data['token_type']) - self.assertEquals(3600, data['expires_in']) + self.assertEquals('3600', data['expires_in'])