Skip to content

Commit d92e902

Browse files
committed
Add test to ensure the ---password option is handled ECFLOW-1865
1 parent b316194 commit d92e902

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Client/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ SET_TARGET_PROPERTIES(ecflow_client PROPERTIES
7272

7373
list( APPEND test_srcs
7474
test/TestClientEnvironment.cpp
75+
test/TestClientOptions.cpp
7576
test/TestClientInterface.cpp
7677
test/TestJobGenOnly.cpp
7778
test/TestLifeCycle.cpp

Client/test/TestClientOptions.cpp

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//============================================================================
2+
// Name :
3+
// Author : Avi
4+
// Revision : $Revision: #9 $
5+
//
6+
// Copyright 2009- ECMWF.
7+
// This software is licensed under the terms of the Apache Licence version 2.0
8+
// which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
9+
// In applying this licence, ECMWF does not waive the privileges and immunities
10+
// granted to it by virtue of its status as an intergovernmental organisation
11+
// nor does it submit to any jurisdiction.
12+
//
13+
// Description : Tests the capabilities of ClientOptions
14+
//============================================================================
15+
#include <boost/test/unit_test.hpp>
16+
17+
#include "ClientEnvironment.hpp"
18+
#include "ClientOptions.hpp"
19+
#include "PasswordEncryption.hpp"
20+
21+
BOOST_AUTO_TEST_SUITE(ClientTestSuite)
22+
23+
BOOST_AUTO_TEST_CASE(test_is_able_to_process_username_and_password) {
24+
const char* expected_username = "username";
25+
const char* plain_password = "password";
26+
std::string expected_password = PasswordEncryption::encrypt(plain_password, expected_username);
27+
28+
const char* argv[]{"ecflow_client", "--user", expected_username, "--password", plain_password, "--ping"};
29+
int argc = boost::size(argv);
30+
31+
ClientOptions options;
32+
ClientEnvironment environment(false);
33+
options.parse(argc, const_cast<char**>(argv), &environment);
34+
35+
std::string actual_username = environment.get_user_name();
36+
BOOST_REQUIRE(expected_username == actual_username);
37+
38+
std::string actual_password = environment.get_user_password(expected_username);
39+
BOOST_REQUIRE(expected_password == actual_password);
40+
}
41+
42+
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)