Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cppinttest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
caosdb
Software
caosdb-cppinttest
Commits
1d3a7b51
Verified
Commit
1d3a7b51
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: authentication
parent
c2cb19ec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#9461
passed
3 years ago
Stage: info
Stage: setup
Stage: build
Stage: test
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_connection.cpp
+31
-15
31 additions, 15 deletions
test/test_connection.cpp
with
31 additions
and
15 deletions
test/test_connection.cpp
+
31
−
15
View file @
1d3a7b51
...
...
@@ -21,6 +21,7 @@
*/
#include
"connection.h"
#include
"authentication.h"
#include
<gtest/gtest-message.h>
#include
<gtest/gtest-test-part.h>
#include
<memory>
...
...
@@ -30,8 +31,8 @@
using
caosdb
::
info
::
v1alpha1
::
VersionInfo
;
TEST
(
test_connection
,
config_somehost_25323
)
{
int
port
=
25323
;
std
::
string
host
=
"somehost"
;
auto
port
=
25323
;
auto
host
=
"somehost"
;
auto
config
=
std
::
make_unique
<
caosdb
::
InsecureCaosDBConnectionConfig
>
(
host
,
port
);
ASSERT_EQ
(
host
,
config
->
getHost
());
...
...
@@ -39,8 +40,8 @@ TEST(test_connection, config_somehost_25323) {
}
TEST
(
test_connection
,
connect_somehost_42347_fails
)
{
int
port
=
42347
;
std
::
string
host
=
"somehost"
;
auto
port
=
42347
;
auto
host
=
"somehost"
;
auto
config
=
std
::
make_shared
<
caosdb
::
InsecureCaosDBConnectionConfig
>
(
host
,
port
);
caosdb
::
CaosDBConnection
connection
(
config
);
...
...
@@ -48,11 +49,10 @@ TEST(test_connection, connect_somehost_42347_fails) {
}
TEST
(
test_connection
,
connection_caosdb_server_insecure_success
)
{
int
port
=
8080
;
const
std
::
string
host
=
caosdb
::
utils
::
get_env_var
(
"CAOSDB_SERVER_HOST"
,
"localhost"
);
int
major
=
0
;
int
minor
=
5
;
int
patch
=
0
;
auto
port
=
8080
;
const
auto
host
=
caosdb
::
utils
::
get_env_var
(
"CAOSDB_SERVER_HOST"
,
"localhost"
);
auto
major
=
0
;
auto
minor
=
5
;
auto
config
=
std
::
make_shared
<
caosdb
::
InsecureCaosDBConnectionConfig
>
(
host
,
port
);
auto
connection
=
caosdb
::
CaosDBConnection
(
config
);
...
...
@@ -63,12 +63,11 @@ TEST(test_connection, connection_caosdb_server_insecure_success) {
}
TEST
(
test_connection
,
connection_caosdb_server_ssl_success
)
{
int
port
=
8443
;
const
std
::
string
host
=
caosdb
::
utils
::
get_env_var
(
"CAOSDB_SERVER_HOST"
,
"localhost"
);
const
std
::
string
path
=
caosdb
::
utils
::
get_env_var
(
"CAOSDB_SERVER_CA_PEM"
,
std
::
string
());
int
major
=
0
;
int
minor
=
5
;
int
patch
=
0
;
auto
port
=
8443
;
const
auto
host
=
caosdb
::
utils
::
get_env_var
(
"CAOSDB_SERVER_HOST"
,
"localhost"
);
const
auto
path
=
caosdb
::
utils
::
get_env_var
(
"CAOSDB_SERVER_CA_PEM"
,
std
::
string
());
auto
major
=
0
;
auto
minor
=
5
;
auto
ssloptions
=
std
::
make_shared
<
caosdb
::
PemFileCACertProvider
>
(
path
);
auto
config
=
std
::
make_shared
<
caosdb
::
SslCaosDBConnectionConfig
>
(
host
,
port
,
ssloptions
);
...
...
@@ -78,3 +77,20 @@ TEST(test_connection, connection_caosdb_server_ssl_success) {
ASSERT_EQ
(
major
,
v_info
.
major
());
ASSERT_EQ
(
minor
,
v_info
.
minor
());
}
TEST
(
test_connection
,
connection_with_authentication_success
)
{
auto
port
=
8443
;
const
auto
host
=
caosdb
::
utils
::
get_env_var
(
"CAOSDB_SERVER_HOST"
,
"localhost"
);
const
auto
path
=
caosdb
::
utils
::
get_env_var
(
"CAOSDB_SERVER_CA_PEM"
,
std
::
string
());
auto
major
=
0
;
auto
minor
=
5
;
auto
auth
=
std
::
make_shared
<
caosdb
::
authentication
::
PlainPasswordAuthenticator
>
(
"caosdb"
,
"admin"
);
auto
ssloptions
=
std
::
make_shared
<
caosdb
::
PemFileCACertProvider
>
(
path
);
auto
config
=
std
::
make_shared
<
caosdb
::
SslCaosDBConnectionConfig
>
(
host
,
port
,
ssloptions
,
auth
);
auto
connection
=
caosdb
::
CaosDBConnection
(
config
);
auto
v_info
=
connection
.
getVersionInfo
();
ASSERT_EQ
(
major
,
v_info
.
major
());
ASSERT_EQ
(
minor
,
v_info
.
minor
());
}
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