mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2026-11-10 05:47:08 +01:00
Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
This commit is contained in:
1 parent
e0e34b4030
commit
4a6bfc086c
6219 files changed
+1209835
-454916
No files matched your search
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// OAuth20CredentialsTest.cpp
|
||||
//
|
||||
// Copyright (c) 2014, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#include "OAuth20CredentialsTest.h"
|
||||
#include "CppUnit/TestCaller.h"
|
||||
#include "CppUnit/TestSuite.h"
|
||||
#include "Poco/Net/HTTPRequest.h"
|
||||
#include "Poco/Net/OAuth20Credentials.h"
|
||||
#include "Poco/Net/NetException.h"
|
||||
|
||||
|
||||
using Poco::Net::HTTPRequest;
|
||||
using Poco::Net::OAuth20Credentials;
|
||||
using Poco::Net::NotAuthenticatedException;
|
||||
|
||||
|
||||
OAuth20CredentialsTest::OAuth20CredentialsTest(const std::string& name): CppUnit::TestCase(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
OAuth20CredentialsTest::~OAuth20CredentialsTest()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void OAuth20CredentialsTest::testAuthorize()
|
||||
{
|
||||
OAuth20Credentials creds("s3cr3tt0k3n");
|
||||
HTTPRequest request(HTTPRequest::HTTP_GET, "/");
|
||||
creds.authenticate(request);
|
||||
std::string auth = request.get("Authorization");
|
||||
assertTrue (auth == "Bearer s3cr3tt0k3n");
|
||||
}
|
||||
|
||||
|
||||
void OAuth20CredentialsTest::testAuthorizeCustomScheme()
|
||||
{
|
||||
OAuth20Credentials creds("s3cr3tt0k3n", "token");
|
||||
HTTPRequest request(HTTPRequest::HTTP_GET, "/");
|
||||
creds.authenticate(request);
|
||||
std::string auth = request.get("Authorization");
|
||||
assertTrue (auth == "token s3cr3tt0k3n");
|
||||
}
|
||||
|
||||
|
||||
void OAuth20CredentialsTest::testExtract()
|
||||
{
|
||||
HTTPRequest request(HTTPRequest::HTTP_GET, "/");
|
||||
request.set("Authorization", "Bearer s3cr3tt0k3n");
|
||||
OAuth20Credentials creds(request);
|
||||
assertTrue (creds.getBearerToken() == "s3cr3tt0k3n");
|
||||
}
|
||||
|
||||
|
||||
void OAuth20CredentialsTest::testExtractCustomScheme()
|
||||
{
|
||||
HTTPRequest request(HTTPRequest::HTTP_GET, "/");
|
||||
request.set("Authorization", "token s3cr3tt0k3n");
|
||||
OAuth20Credentials creds(request, "token");
|
||||
assertTrue (creds.getBearerToken() == "s3cr3tt0k3n");
|
||||
}
|
||||
|
||||
|
||||
void OAuth20CredentialsTest::testExtractNoCreds()
|
||||
{
|
||||
HTTPRequest request(HTTPRequest::HTTP_GET, "/");
|
||||
try
|
||||
{
|
||||
OAuth20Credentials creds(request);
|
||||
fail("no credentials - must throw");
|
||||
}
|
||||
catch (NotAuthenticatedException&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OAuth20CredentialsTest::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void OAuth20CredentialsTest::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CppUnit::Test* OAuth20CredentialsTest::suite()
|
||||
{
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("OAuth20CredentialsTest");
|
||||
|
||||
CppUnit_addTest(pSuite, OAuth20CredentialsTest, testAuthorize);
|
||||
CppUnit_addTest(pSuite, OAuth20CredentialsTest, testAuthorizeCustomScheme);
|
||||
CppUnit_addTest(pSuite, OAuth20CredentialsTest, testExtract);
|
||||
CppUnit_addTest(pSuite, OAuth20CredentialsTest, testExtractCustomScheme);
|
||||
CppUnit_addTest(pSuite, OAuth20CredentialsTest, testExtractNoCreds);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
Reference in new issue
Block a user