|
| 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