-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
created initial test case for globus api #1050
Open
nedvedba
wants to merge
7
commits into
1066-bug-fix
Choose a base branch
from
1044-bug-fix
base: 1066-bug-fix
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d4bc79b
created initial test case for globus api
nedvedba 2a4d6f8
created a test class header for globus api
nedvedba a81f6b5
moved test class definition into test file
nedvedba deecc35
added function definitions and initial per test case setup
nedvedba f1714b8
finished tests
nedvedba f918741
added missing curl method
nedvedba 8368820
Merge pull request #1049 from ORNL/1043-bug-fix
JoshuaSBrown File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#define BOOST_TEST_MAIN | ||
|
||
#define BOOST_TEST_MODULE globusapi | ||
|
||
// Local private includes | ||
#include "GlobusAPI.hpp" | ||
// #include "Config.hpp" | ||
|
||
// Local public includes | ||
#include "common/DynaLog.hpp" | ||
#include "common/libjson.hpp" | ||
#include "common/Util.hpp" | ||
|
||
// Third party includes | ||
#include <curl/curl.h> | ||
#include <boost/algorithm/string/predicate.hpp> | ||
#include <boost/filesystem.hpp> | ||
#include <boost/test/unit_test.hpp> | ||
|
||
// Standard includes | ||
#include <string> | ||
#include <vector> | ||
#include <map> | ||
#include <memory> | ||
|
||
using namespace libjson; | ||
using namespace SDMS::Core; | ||
|
||
class TestGlobusAPI: public GlobusAPI { | ||
public: | ||
TestGlobusAPI() {} | ||
|
||
~TestGlobusAPI() {} | ||
|
||
void setupConfig() { | ||
|
||
} | ||
|
||
long get(CURL *a_curl, const std::string &a_base_url, | ||
const std::string &a_url_path, const std::string &a_token, | ||
const std::vector<std::pair<std::string, std::string>> &a_params, | ||
std::string &a_result) { | ||
return GlobusAPI::get(a_curl, a_base_url, a_url_path, a_token, a_params, a_result); | ||
} | ||
|
||
long post(CURL *a_curl, const std::string &a_base_url, | ||
const std::string &a_url_path, const std::string &a_token, | ||
const std::vector<std::pair<std::string, std::string>> &a_params, | ||
const libjson::Value *a_body, std::string &a_result) { | ||
return GlobusAPI::post(a_curl, a_base_url, a_url_path, a_token, a_params, a_body, a_result); | ||
} | ||
}; | ||
|
||
CURL* curl_setup() { | ||
CURL* m_curl = curl_easy_init(); | ||
if (!m_curl) | ||
EXCEPT(1, "libcurl init failed"); | ||
|
||
curl_easy_setopt(m_curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, curlResponseWriteCB); | ||
curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYPEER, 0); | ||
curl_easy_setopt(m_curl, CURLOPT_TCP_NODELAY, 1); | ||
} | ||
|
||
BOOST_AUTO_TEST_SUITE(GlobusAPITest) | ||
|
||
BOOST_AUTO_TEST_CASE(testing_GlobusAPIPost) { | ||
TestGlobusAPI api; | ||
api.setupConfig(); | ||
CURL* m_curl = curl_setup(); | ||
Value body; | ||
Value::Object &body_o = body.initObject(); | ||
body_o["username"] = "admin"; | ||
body_o["password"] = "password123"; | ||
std::string res; | ||
|
||
api.post(m_curl, "https://restful-booker.herokuapp.com/", "auth", "", {{"field","test"}}, &body, res); | ||
|
||
BOOST_TEST(true); | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(testing_GlobusAPIGet) { | ||
TestGlobusAPI api; | ||
api.setupConfig(); | ||
CURL* m_curl = curl_setup(); | ||
std::string res; | ||
|
||
api.get(m_curl, "https://restful-booker.herokuapp.com/", "booking", "authtoken", {{"field","test"}}, res); | ||
|
||
BOOST_TEST(true); | ||
} | ||
|
||
BOOST_AUTO_TEST_SUITE_END() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (testing): Empty test case for GlobusAPIGet
This test case is currently just asserting true, which doesn't validate any actual functionality. Consider adding meaningful assertions that verify the GET request behavior, including successful responses, error handling, and edge cases like invalid endpoints or authentication failures.