blob: 728eed68061f0d91ec288f15d633845d61fbf6a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/*
* Copyright (c) 2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <QA/Checker/IO.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <Swiften/SASL/EXTERNALClientAuthenticator.h>
using namespace Swift;
class EXTERNALClientAuthenticatorTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(EXTERNALClientAuthenticatorTest);
CPPUNIT_TEST(testGetResponse_WithoutAuthzID);
CPPUNIT_TEST(testGetResponse_WithAuthzID);
CPPUNIT_TEST_SUITE_END();
public:
void testGetResponse_WithoutAuthzID() {
EXTERNALClientAuthenticator testling;
// Authcid and password are not used (ignored)
testling.setCredentials("user", createSafeByteArray("pass"));
boost::optional<SafeByteArray> response = testling.getResponse();
// No data should have been returned
bool result = !response;
CPPUNIT_ASSERT(result);
}
void testGetResponse_WithAuthzID() {
EXTERNALClientAuthenticator testling;
// Authcid and password are not used (ignored)
testling.setCredentials("user", createSafeByteArray("pass"), "authz");
CPPUNIT_ASSERT_EQUAL(*testling.getResponse(), createSafeByteArray("authz", 5));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(EXTERNALClientAuthenticatorTest);
|