tests/auto/qsslcertificate/tst_qsslcertificate.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 0 1918ee327afb
child 5 d3bac044e0f0
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the test suite of the Qt Toolkit.
     7 ** This file is part of the test suite of the Qt Toolkit.
     8 **
     8 **
   103     void toPemOrDer();
   103     void toPemOrDer();
   104     void fromDevice();
   104     void fromDevice();
   105     void fromPath_data();
   105     void fromPath_data();
   106     void fromPath();
   106     void fromPath();
   107     void certInfo();
   107     void certInfo();
       
   108     void certInfoQByteArray();
   108     void task256066toPem();
   109     void task256066toPem();
   109     void nulInCN();
   110     void nulInCN();
   110     void nulInSan();
   111     void nulInSan();
   111 // ### add tests for certificate bundles (multiple certificates concatenated into a single
   112 // ### add tests for certificate bundles (multiple certificates concatenated into a single
   112 //     structure); both PEM and DER formatted
   113 //     structure); both PEM and DER formatted
   695 
   696 
   696     QCOMPARE(cert, QSslCertificate(pem, QSsl::Pem));
   697     QCOMPARE(cert, QSslCertificate(pem, QSsl::Pem));
   697     QCOMPARE(cert, QSslCertificate(QByteArray::fromHex(der), QSsl::Der));
   698     QCOMPARE(cert, QSslCertificate(QByteArray::fromHex(der), QSsl::Der));
   698 }
   699 }
   699 
   700 
       
   701 void tst_QSslCertificate::certInfoQByteArray()
       
   702 {
       
   703     QSslCertificate cert =  QSslCertificate::fromPath("certificates/cert.pem", QSsl::Pem,
       
   704                                                       QRegExp::FixedString).first();
       
   705     QVERIFY(!cert.isNull());
       
   706 
       
   707     // in this test, check the bytearray variants before the enum variants to see if
       
   708     // we fixed a bug we had with lazy initialization of the values.
       
   709     QCOMPARE(cert.issuerInfo("CN"), QString("Test CA (1024 bit)"));
       
   710     QCOMPARE(cert.subjectInfo("CN"), QString("name/with/slashes"));
       
   711 }
       
   712 
   700 void tst_QSslCertificate::task256066toPem()
   713 void tst_QSslCertificate::task256066toPem()
   701 {
   714 {
   702     // a certificate whose PEM encoding's length is a multiple of 64
   715     // a certificate whose PEM encoding's length is a multiple of 64
   703     const char *mycert = "-----BEGIN CERTIFICATE-----\n" \
   716     const char *mycert = "-----BEGIN CERTIFICATE-----\n" \
   704                          "MIIEGjCCAwKgAwIBAgIESikYSjANBgkqhkiG9w0BAQUFADBbMQswCQYDVQQGEwJF\n" \
   717                          "MIIEGjCCAwKgAwIBAgIESikYSjANBgkqhkiG9w0BAQUFADBbMQswCQYDVQQGEwJF\n" \