blob: 59aee47e923869a6a3a0905a1aa95ea2de5bec01 (
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
48
49
50
51
52
53
54
55
56
|
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <boost/bind.hpp>
#include "Swiften/TLS/OpenSSL/OpenSSLCertificate.h"
#include "SwifTools/Application/PlatformApplicationPathProvider.h"
using namespace Swift;
class OpenSSLCertificateTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(OpenSSLCertificateTest);
CPPUNIT_TEST(testConstructFromDER);
CPPUNIT_TEST(testToDER);
CPPUNIT_TEST(testGetSubjectName);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
pathProvider = new PlatformApplicationPathProvider("FileReadBytestreamTest");
certificateData.readFromFile((pathProvider->getExecutableDir() / "jabber_org.crt").string());
}
void tearDown() {
delete pathProvider;
}
void testConstructFromDER() {
OpenSSLCertificate testling(certificateData);
CPPUNIT_ASSERT_EQUAL(String("*.jabber.org"), testling.getCommonNames()[0]);
}
void testToDER() {
OpenSSLCertificate testling(certificateData);
CPPUNIT_ASSERT_EQUAL(certificateData, testling.toDER());
}
void testGetSubjectName() {
OpenSSLCertificate testling(certificateData);
CPPUNIT_ASSERT_EQUAL(String("/description=114072-VMk8pdi1aj5kTXxO/C=US/ST=Colorado/L=Denver/O=Peter Saint-Andre/OU=StartCom Trusted Certificate Member/CN=*.jabber.org/emailAddress=hostmaster@jabber.org"), testling.getSubjectName());
}
private:
PlatformApplicationPathProvider* pathProvider;
ByteArray certificateData;
};
CPPUNIT_TEST_SUITE_REGISTRATION(OpenSSLCertificateTest);
|