Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
bitmask-vpn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
leap
bitmask-vpn
Commits
0d3d6253
Verified
Commit
0d3d6253
authored
8 months ago
by
Pea Nut
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for IsValidCert
parent
c9c4f665
Branches
main
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#225899
passed
8 months ago
Stage: build
Stage: debian
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/vpn/utils_test.go
+53
-0
53 additions, 0 deletions
pkg/vpn/utils_test.go
with
53 additions
and
0 deletions
pkg/vpn/utils_test.go
0 → 100644
+
53
−
0
View file @
0d3d6253
package
vpn
import
(
"os"
"testing"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/require"
)
func
init
()
{
log
.
Logger
=
zerolog
.
New
(
zerolog
.
ConsoleWriter
{
Out
:
os
.
Stdout
})
.
With
()
.
Timestamp
()
.
Logger
()
}
func
TestIsValidCertExpired
(
t
*
testing
.
T
)
{
certFile
:=
"testdata/expired.pem"
require
.
False
(
t
,
isValidCert
(
certFile
),
"The test with the expired pem failed"
)
}
func
TestIsValidCertEmpty
(
t
*
testing
.
T
)
{
certFile
:=
"testdata/empty.pem"
require
.
False
(
t
,
isValidCert
(
certFile
),
"The test with the empty pem file failed"
)
}
func
TestIsValidCertKeyMissing
(
t
*
testing
.
T
)
{
certFile
:=
"testdata/privatekeymissing.pem"
require
.
False
(
t
,
isValidCert
(
certFile
),
"The test with the missing private key failed"
)
}
func
TestIsValidCertBroken
(
t
*
testing
.
T
)
{
certFile
:=
"testdata/broken.pem"
require
.
False
(
t
,
isValidCert
(
certFile
),
"The test with the broken pem file failed"
)
}
// TODO: make this backend agnostic, currently only works with menshen https://0xacab.org/leap/bitmask-vpn/-/issues/825
//func TestIsValidCertFromMenshenValid(t *testing.T) {
// // needs API_URL="http://localhost:8443" via env
// m, err := menshen.New()
// require.NoError(t, err, "Could not create menshen instance")
//
// tmpFile, err := ioutil.TempFile(os.TempDir(), "leap-client-cert.pem")
// require.NoError(t, err, "Could not create tmp file for OpenVPN client credentials")
// defer os.Remove(tmpFile.Name())
//
// cert, err := m.GetPemCertificate()
// require.NoError(t, err, "Could not get PEM certificate from menshen")
//
// _, err = tmpFile.Write(cert)
// require.NoError(t, err, "Could not write to tmp OpenVPN client credentials file")
//
// assert.True(t, isValidCert(tmpFile.Name()), "PEM file from Menshen is not a valid certificate")
//}
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