Skip to content
Permalink
Browse files
Upgrade database definition
  • Loading branch information
brogand93 committed Jul 27, 2014
1 parent 4219ecc commit 8f36cd1b5696dab1b91842e1ad21ebf0af5bd2f6
Showing 6 changed files with 53 additions and 18 deletions.
@@ -28,7 +28,7 @@
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,
@@ -148,6 +148,7 @@ def get_authorization_header(self):
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)
@@ -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
@@ -16,7 +16,10 @@

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),
@@ -25,10 +28,6 @@ def upgrade():
'expires_in',
sa.String(length=10),
nullable=True),
sa.Column(
'id_token',
sa.String(length=1000),
nullable=True),
sa.Column(
'data',
sa.String(length=500),
@@ -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
@@ -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
@@ -57,7 +57,7 @@ def persist_authorization_code(self, client_id, code, scope):

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 @@ def test_get_token_with_valid_authorization_code(self):
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'])

0 comments on commit 8f36cd1

Please sign in to comment.