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
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
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
Hide 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:
...
@@ -23,3 +23,15 @@ except ImportError:
from
pkgutil
import
extend_path
from
pkgutil
import
extend_path
__path__
=
extend_path
(
__path__
,
__name__
)
__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
...
@@ -22,7 +22,7 @@ import uuid
import
hashlib
import
hashlib
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
OpenSSL
import
crypto
from
OpenSSL
import
crypto
from
caucase
.web
import
db
from
caucase
import
db
from
caucase
import
utils
from
caucase
import
utils
from
caucase.exceptions
import
(
NoStorage
,
NotFound
,
Found
)
from
caucase.exceptions
import
(
NoStorage
,
NotFound
,
Found
)
from
flask_user
import
UserMixin
from
flask_user
import
UserMixin
...
...
caucase/test/testca.py
View file @
2d6b3bed
...
@@ -23,7 +23,7 @@ import tempfile
...
@@ -23,7 +23,7 @@ import tempfile
import
unittest
import
unittest
import
json
import
json
from
datetime
import
datetime
from
datetime
import
datetime
from
caucase
.web
import
app
,
db
from
caucase
import
app
,
db
from
OpenSSL
import
crypto
,
SSL
from
OpenSSL
import
crypto
,
SSL
from
caucase.exceptions
import
(
NoStorage
,
NotFound
,
Found
,
BadSignature
,
from
caucase.exceptions
import
(
NoStorage
,
NotFound
,
Found
,
BadSignature
,
BadCertificateSigningRequest
,
BadCertificateSigningRequest
,
...
...
caucase/test/testcaweb.py
View file @
2d6b3bed
...
@@ -27,6 +27,7 @@ from caucase.web import parseArguments, configure_flask
...
@@ -27,6 +27,7 @@ from caucase.web import parseArguments, configure_flask
from
OpenSSL
import
crypto
,
SSL
from
OpenSSL
import
crypto
,
SSL
from
caucase.exceptions
import
(
NoStorage
,
NotFound
,
Found
)
from
caucase.exceptions
import
(
NoStorage
,
NotFound
,
Found
)
from
caucase
import
utils
from
caucase
import
utils
from
caucase
import
db
,
app
from
flask_testing
import
TestCase
from
flask_testing
import
TestCase
from
flask
import
url_for
from
flask
import
url_for
...
@@ -37,14 +38,12 @@ class CertificateAuthorityWebTest(TestCase):
...
@@ -37,14 +38,12 @@ class CertificateAuthorityWebTest(TestCase):
configure_flask
(
parseArguments
([
'--ca-dir'
,
self
.
ca_dir
,
'-s'
,
'/CN=CA Auth Test/emailAddress=xx@example.com'
]))
configure_flask
(
parseArguments
([
'--ca-dir'
,
self
.
ca_dir
,
'-s'
,
'/CN=CA Auth Test/emailAddress=xx@example.com'
]))
def
tearDown
(
self
):
def
tearDown
(
self
):
from
caucase.web
import
db
db
.
session
.
remove
()
db
.
session
.
remove
()
db
.
drop_all
()
db
.
drop_all
()
if
os
.
path
.
exists
(
self
.
ca_dir
):
if
os
.
path
.
exists
(
self
.
ca_dir
):
shutil
.
rmtree
(
self
.
ca_dir
)
shutil
.
rmtree
(
self
.
ca_dir
)
def
create_app
(
self
):
def
create_app
(
self
):
from
caucase.web
import
app
app
.
config
[
'TESTING'
]
=
True
app
.
config
[
'TESTING'
]
=
True
app
.
config
[
'LIVESERVER_PORT'
]
=
0
app
.
config
[
'LIVESERVER_PORT'
]
=
0
return
app
return
app
...
...
caucase/test/teststorage.py
View file @
2d6b3bed
...
@@ -23,7 +23,8 @@ import tempfile
...
@@ -23,7 +23,8 @@ import tempfile
import
unittest
import
unittest
import
json
import
json
from
datetime
import
datetime
,
timedelta
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
OpenSSL
import
crypto
,
SSL
from
caucase.exceptions
import
(
NoStorage
,
NotFound
,
Found
)
from
caucase.exceptions
import
(
NoStorage
,
NotFound
,
Found
)
from
sqlite3
import
IntegrityError
from
sqlite3
import
IntegrityError
...
@@ -45,12 +46,11 @@ class StorageTest(unittest.TestCase):
...
@@ -45,12 +46,11 @@ class StorageTest(unittest.TestCase):
TESTING
=
True
,
TESTING
=
True
,
SQLALCHEMY_DATABASE_URI
=
'sqlite:///%s'
%
self
.
db_file
SQLALCHEMY_DATABASE_URI
=
'sqlite:///%s'
%
self
.
db_file
)
)
from
caucase.storage
import
Storage
self
.
_storage
=
Storage
(
db
)
self
.
_storage
=
Storage
(
db
)
def
setConfig
(
self
,
key
,
value
):
def
setConfig
(
self
,
key
,
value
):
entry
=
self
.
_storage
.
_getConfig
(
key
)
entry
=
self
.
_storage
.
_getConfig
(
key
)
from
caucase.storage
import
Config
if
not
entry
:
if
not
entry
:
entry
=
Config
(
key
=
key
,
value
=
'%s'
%
value
)
entry
=
Config
(
key
=
key
,
value
=
'%s'
%
value
)
db
.
session
.
add
(
entry
)
db
.
session
.
add
(
entry
)
...
...
caucase/web.py
View file @
2d6b3bed
...
@@ -23,9 +23,8 @@ import argparse
...
@@ -23,9 +23,8 @@ import argparse
import
traceback
import
traceback
import
json
import
json
import
flask
import
flask
from
flask
import
(
Flask
,
session
,
request
,
redirect
,
url_for
,
render_template
,
from
flask
import
(
session
,
request
,
redirect
,
url_for
,
render_template
,
jsonify
,
session
,
abort
,
send_file
,
flash
,
g
,
Response
)
jsonify
,
abort
,
send_file
,
flash
,
g
,
Response
)
from
flask_sqlalchemy
import
SQLAlchemy
from
flask_user
import
UserManager
,
SQLAlchemyAdapter
from
flask_user
import
UserManager
,
SQLAlchemyAdapter
from
wtforms
import
StringField
,
SubmitField
,
validators
from
wtforms
import
StringField
,
SubmitField
,
validators
from
flask_wtf
import
FlaskForm
from
flask_wtf
import
FlaskForm
...
@@ -40,13 +39,7 @@ from caucase.exceptions import (NoStorage, NotFound, Found, BadSignature,
...
@@ -40,13 +39,7 @@ from caucase.exceptions import (NoStorage, NotFound, Found, BadSignature,
ExpiredCertificate
)
ExpiredCertificate
)
from
functools
import
wraps
from
functools
import
wraps
from
caucase
import
utils
from
caucase
import
utils
from
caucase
import
app
,
db
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
)
class
DisabledStringField
(
StringField
):
class
DisabledStringField
(
StringField
):
def
__call__
(
self
,
*
args
,
**
kwargs
):
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