-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HttpClient is injected into ApiClient
- Loading branch information
1 parent
6c07589
commit 9902621
Showing
10 changed files
with
101 additions
and
17 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef __LAUTH_HTTP_CLIENT_HPP__ | ||
#define __LAUTH_HTTP_CLIENT_HPP__ | ||
|
||
#include "lauth/request.hpp" | ||
|
||
namespace mlibrary::lauth { | ||
class HttpClient { | ||
public: | ||
virtual ~HttpClient() = default; | ||
|
||
virtual bool isAllowed(Request req); | ||
}; | ||
} | ||
|
||
#endif // __LAUTH_HTTP_CLIENT_HPP__ |
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 |
---|---|---|
@@ -1,11 +1,8 @@ | ||
#include "lauth/api_client.hpp" | ||
|
||
// #include <string> | ||
|
||
namespace mlibrary::lauth { | ||
bool ApiClient::isAllowed(Request req) { | ||
return req.user.size() > 0; | ||
// bool result = http_client(req.uri, req.user); | ||
return client->isAllowed(req); | ||
} | ||
} | ||
|
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,8 @@ | ||
#include "lauth/http_client.hpp" | ||
|
||
namespace mlibrary::lauth { | ||
bool HttpClient::isAllowed(Request req) { | ||
return (req.user == "authorized"); | ||
} | ||
} | ||
|
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,18 @@ | ||
#include <gtest/gtest.h> | ||
#include <gmock/gmock.h> | ||
|
||
using testing::_; | ||
|
||
#include "lauth/http_client.hpp" | ||
#include "lauth/request.hpp" | ||
|
||
using namespace mlibrary::lauth; | ||
|
||
TEST(HttpClient, a_request_with_authorized_user_is_allowed) { | ||
HttpClient client; | ||
Request request; | ||
|
||
request.user = "authorized"; | ||
bool result = client.isAllowed(request); | ||
EXPECT_THAT(result, true); | ||
} |
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