Commit 55bbc07 1 parent f849556 commit 55bbc07 Copy full SHA for 55bbc07
File tree 3 files changed +54
-2
lines changed
3 files changed +54
-2
lines changed Original file line number Diff line number Diff line change 21
21
// SOFTWARE.
22
22
23
23
#include " SystemTest.h"
24
+ #include " InfluxDBBuilder.h"
24
25
25
26
namespace influxdb ::test
26
27
{
@@ -43,4 +44,29 @@ namespace influxdb::test
43
44
CHECK_THAT (response, ContainsSubstring (user.name ));
44
45
}
45
46
}
47
+
48
+ TEST_CASE (" Http authentication methods" , " [HttpAuthTest]" )
49
+ {
50
+ using Catch::Matchers::ContainsSubstring;
51
+
52
+ const auto user = getUserFromEnv ();
53
+
54
+ SECTION (" Authenticate through factory" )
55
+ {
56
+ auto db = InfluxDBFactory::Get (" http://" + (user.name + " :" + user.pass + " @" ) + getHostFromEnv () + " :8086?db=ignore" );
57
+
58
+ const auto response = db->execute (" show users" );
59
+ CHECK_THAT (response, ContainsSubstring (user.name ));
60
+ }
61
+
62
+ SECTION (" Authenticate through builder" )
63
+ {
64
+ auto db = InfluxDBBuilder::http (" http://" + getHostFromEnv () + " :8086?db=ignore" )
65
+ .setBasicAuthentication (user.name , user.pass )
66
+ .connect ();
67
+
68
+ const auto response = db->execute (" show users" );
69
+ CHECK_THAT (response, ContainsSubstring (user.name ));
70
+ }
71
+ }
46
72
}
Original file line number Diff line number Diff line change 21
21
// SOFTWARE.
22
22
23
23
#include " SystemTest.h"
24
+ #include " InfluxDBBuilder.h"
24
25
25
26
namespace influxdb ::test
26
27
{
@@ -38,6 +39,27 @@ namespace influxdb::test
38
39
}
39
40
}
40
41
42
+ TEST_CASE (" Connection configuration" , " [InfluxDBST]" )
43
+ {
44
+ using namespace Catch ::Matchers;
45
+
46
+ SECTION (" Connect through factory" )
47
+ {
48
+ auto db = InfluxDBFactory::Get (" http://" + getHostFromEnv () + " :8086?db=ignore" );
49
+ const auto response = db->execute (" show databases" );
50
+ CHECK (response.empty () == false );
51
+ }
52
+
53
+ SECTION (" Connect through builder" )
54
+ {
55
+ auto db = InfluxDBBuilder::http (" http://" + getHostFromEnv () + " :8086?db=ignore" )
56
+ .setTimeout (std::chrono::seconds{5 })
57
+ .connect ();
58
+ const auto response = db->execute (" show databases" );
59
+ CHECK (response.empty () == false );
60
+ }
61
+ }
62
+
41
63
TEST_CASE (" InfluxDB system test" , " [InfluxDBST]" )
42
64
{
43
65
using namespace Catch ::Matchers;
Original file line number Diff line number Diff line change @@ -61,10 +61,14 @@ namespace influxdb::test
61
61
return {*user, *pass};
62
62
}
63
63
64
+ inline std::string getHostFromEnv ()
65
+ {
66
+ return getEnv (" INFLUXDBCXX_SYSTEMTEST_HOST" ).value_or (" localhost" );
67
+ }
68
+
64
69
inline std::unique_ptr<InfluxDB> configure (const std::string& db, std::optional<User> user = {})
65
70
{
66
- const auto host = getEnv (" INFLUXDBCXX_SYSTEMTEST_HOST" ).value_or (" localhost" );
67
71
const std::string authString{user ? (user->name + " :" + user->pass + " @" ) : " " };
68
- return InfluxDBFactory::Get (" http://" + authString + host + " :8086?db=" + db);
72
+ return InfluxDBFactory::Get (" http://" + authString + getHostFromEnv () + " :8086?db=" + db);
69
73
}
70
74
}
You can’t perform that action at this time.
0 commit comments