Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autoca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ai
autoca
Commits
d14b24b0
Commit
d14b24b0
authored
12 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
add tests for vpn_app; fix error in to_pkcs12()
parent
1adf6ab2
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
autovpn/test/__init__.py
+0
-0
0 additions, 0 deletions
autovpn/test/__init__.py
autovpn/test/test_vpn_app.py
+65
-0
65 additions, 0 deletions
autovpn/test/test_vpn_app.py
autovpn/vpn_app.py
+1
-1
1 addition, 1 deletion
autovpn/vpn_app.py
with
66 additions
and
1 deletion
autovpn/test/__init__.py
0 → 100644
+
0
−
0
View file @
d14b24b0
This diff is collapsed.
Click to expand it.
autovpn/test/test_vpn_app.py
0 → 100644
+
65
−
0
View file @
d14b24b0
import
tempfile
import
shutil
import
unittest
from
flask
import
session
from
autovpn
import
vpn_app
class
VpnAppTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
tmpdir
=
tempfile
.
mkdtemp
()
self
.
config
=
{
'
DEBUG
'
:
'
true
'
,
'
SECRET_KEY
'
:
'
somesecret
'
,
'
VPN_CA_ROOT
'
:
self
.
tmpdir
,
'
VPN_CA_SUBJECT
'
:
{
'
CN
'
:
'
test CA
'
,
'
O
'
:
'
test
'
},
'
VPN_CA_BITS
'
:
1024
,
'
VPN_ENDPOINT
'
:
'
vpn.example.com
'
,
'
VPN_SITE_URL
'
:
'
http://localhost:4000/
'
,
'
FOOTER
'
:
'''
<p class=
"
footer
"
>
built by <a href=
"
http://www.autistici.org/
"
>autistici.org</a>
</p>
'''
,
'
AUTH_ENABLE
'
:
True
,
'
AUTH_FUNCTION
'
:
lambda
x
,
y
:
(
x
and
y
and
x
==
y
),
}
self
.
app
=
vpn_app
.
make_app
(
self
.
config
)
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
tmpdir
)
def
test_login_ok
(
self
):
with
self
.
app
.
test_client
()
as
c
:
rv
=
c
.
get
(
'
/login
'
)
csrf
=
session
[
'
_csrf
'
]
rv
=
c
.
post
(
'
/login
'
,
data
=
{
'
_csrf
'
:
csrf
,
'
username
'
:
'
admin
'
,
'
password
'
:
'
admin
'
},
follow_redirects
=
True
)
self
.
assertTrue
(
'
download of the ZIP file
'
in
rv
.
data
)
def
test_login_fail
(
self
):
with
self
.
app
.
test_client
()
as
c
:
rv
=
c
.
get
(
'
/login
'
)
csrf
=
session
[
'
_csrf
'
]
rv
=
c
.
post
(
'
/login
'
,
data
=
{
'
_csrf
'
:
csrf
,
'
username
'
:
'
user
'
,
'
password
'
:
'
wrong password
'
},
follow_redirects
=
True
)
self
.
assertFalse
(
session
.
get
(
'
dl_ok
'
))
self
.
assertTrue
(
'
Authentication failed
'
in
rv
.
data
)
def
test_cert_dl
(
self
):
with
self
.
app
.
test_client
()
as
c
:
with
c
.
session_transaction
()
as
sess
:
sess
[
'
dl_ok
'
]
=
True
sess
[
'
_csrf
'
]
=
'
csrf
'
sess
[
'
logged_in
'
]
=
True
rv
=
c
.
get
(
'
/newcertdl?_csrf=csrf
'
)
self
.
assertEquals
(
'
200 OK
'
,
rv
.
status
)
self
.
assertEquals
(
'
application/zip
'
,
rv
.
content_type
)
This diff is collapsed.
Click to expand it.
autovpn/vpn_app.py
+
1
−
1
View file @
d14b24b0
...
...
@@ -139,7 +139,7 @@ def to_pkcs12(crt_pem, key_pem, ca_pem):
try
:
for
name
,
content
in
[
(
'
crt.pem
'
,
crt_pem
),
(
'
key.pem
'
,
key_pem
),
(
'
ca.pem
'
,
ca_pem
)]:
with
open
(
os
.
path
.
join
(
tmpdir
,
name
))
as
fd
:
with
open
(
os
.
path
.
join
(
tmpdir
,
name
)
,
'
w
'
)
as
fd
:
fd
.
write
(
content
)
pipe
=
subprocess
.
Popen
(
[
'
openssl
'
,
'
pkcs12
'
,
'
-export
'
,
'
-password
'
,
'
pass:
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment