Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caucase
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Tyagov
caucase
Commits
2d6b3bed
Commit
2d6b3bed
authored
May 24, 2017
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove app, db from web to prevent using a different app_context in tests
parent
6e3bb8e5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
18 deletions
+22
-18
caucase/__init__.py
caucase/__init__.py
+12
-0
caucase/storage.py
caucase/storage.py
+1
-1
caucase/test/testca.py
caucase/test/testca.py
+1
-1
caucase/test/testcaweb.py
caucase/test/testcaweb.py
+1
-2
caucase/test/teststorage.py
caucase/test/teststorage.py
+4
-4
caucase/web.py
caucase/web.py
+3
-10
No files found.
caucase/__init__.py
View file @
2d6b3bed
...
...
@@ -23,3 +23,15 @@ except ImportError:
from
pkgutil
import
extend_path
__path__
=
extend_path
(
__path__
,
__name__
)
from
flask
import
Flask
from
flask_sqlalchemy
import
SQLAlchemy
app
=
Flask
(
__name__
)
# Use default value so SQLALCHEMY will not warn because there is not db_uri
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///ca.db'
app
.
config
[
'SQLALCHEMY_TRACK_MODIFICATIONS'
]
=
False
db
=
SQLAlchemy
(
app
)
from
caucase
import
web
,
storage
\ No newline at end of file
caucase/storage.py
View file @
2d6b3bed
...
...
@@ -22,7 +22,7 @@ import uuid
import
hashlib
from
datetime
import
datetime
,
timedelta
from
OpenSSL
import
crypto
from
caucase
.web
import
db
from
caucase
import
db
from
caucase
import
utils
from
caucase.exceptions
import
(
NoStorage
,
NotFound
,
Found
)
from
flask_user
import
UserMixin
...
...
caucase/test/testca.py
View file @
2d6b3bed
...
...
@@ -23,7 +23,7 @@ import tempfile
import
unittest
import
json
from
datetime
import
datetime
from
caucase
.web
import
app
,
db
from
caucase
import
app
,
db
from
OpenSSL
import
crypto
,
SSL
from
caucase.exceptions
import
(
NoStorage
,
NotFound
,
Found
,
BadSignature
,
BadCertificateSigningRequest
,
...
...
caucase/test/testcaweb.py
View file @
2d6b3bed
...
...
@@ -27,6 +27,7 @@ from caucase.web import parseArguments, configure_flask
from
OpenSSL
import
crypto
,
SSL
from
caucase.exceptions
import
(
NoStorage
,
NotFound
,
Found
)
from
caucase
import
utils
from
caucase
import
db
,
app
from
flask_testing
import
TestCase
from
flask
import
url_for
...
...
@@ -37,14 +38,12 @@ class CertificateAuthorityWebTest(TestCase):
configure_flask
(
parseArguments
([
'--ca-dir'
,
self
.
ca_dir
,
'-s'
,
'/CN=CA Auth Test/emailAddress=xx@example.com'
]))
def
tearDown
(
self
):
from
caucase.web
import
db
db
.
session
.
remove
()
db
.
drop_all
()
if
os
.
path
.
exists
(
self
.
ca_dir
):
shutil
.
rmtree
(
self
.
ca_dir
)
def
create_app
(
self
):
from
caucase.web
import
app
app
.
config
[
'TESTING'
]
=
True
app
.
config
[
'LIVESERVER_PORT'
]
=
0
return
app
...
...
caucase/test/teststorage.py
View file @
2d6b3bed
...
...
@@ -23,7 +23,8 @@ import tempfile
import
unittest
import
json
from
datetime
import
datetime
,
timedelta
from
caucase.web
import
app
,
db
from
caucase
import
app
,
db
from
caucase.storage
import
Storage
,
Config
from
OpenSSL
import
crypto
,
SSL
from
caucase.exceptions
import
(
NoStorage
,
NotFound
,
Found
)
from
sqlite3
import
IntegrityError
...
...
@@ -45,12 +46,11 @@ class StorageTest(unittest.TestCase):
TESTING
=
True
,
SQLALCHEMY_DATABASE_URI
=
'sqlite:///%s'
%
self
.
db_file
)
from
caucase.storage
import
Storage
self
.
_storage
=
Storage
(
db
)
def
setConfig
(
self
,
key
,
value
):
entry
=
self
.
_storage
.
_getConfig
(
key
)
from
caucase.storage
import
Config
if
not
entry
:
entry
=
Config
(
key
=
key
,
value
=
'%s'
%
value
)
db
.
session
.
add
(
entry
)
...
...
caucase/web.py
View file @
2d6b3bed
...
...
@@ -23,9 +23,8 @@ import argparse
import
traceback
import
json
import
flask
from
flask
import
(
Flask
,
session
,
request
,
redirect
,
url_for
,
render_template
,
jsonify
,
session
,
abort
,
send_file
,
flash
,
g
,
Response
)
from
flask_sqlalchemy
import
SQLAlchemy
from
flask
import
(
session
,
request
,
redirect
,
url_for
,
render_template
,
jsonify
,
abort
,
send_file
,
flash
,
g
,
Response
)
from
flask_user
import
UserManager
,
SQLAlchemyAdapter
from
wtforms
import
StringField
,
SubmitField
,
validators
from
flask_wtf
import
FlaskForm
...
...
@@ -40,13 +39,7 @@ from caucase.exceptions import (NoStorage, NotFound, Found, BadSignature,
ExpiredCertificate
)
from
functools
import
wraps
from
caucase
import
utils
app
=
Flask
(
__name__
)
# Use default value so SQLALCHEMY will not warn because there is not db_uri
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///ca.db'
app
.
config
[
'SQLALCHEMY_TRACK_MODIFICATIONS'
]
=
False
db
=
SQLAlchemy
(
app
)
from
caucase
import
app
,
db
class
DisabledStringField
(
StringField
):
def
__call__
(
self
,
*
args
,
**
kwargs
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment