ENGINE-171: test for case changes and dot addresses ENGINE-171
authorKrista Bennett <krista@pep-project.org>
Wed, 28 Jun 2017 10:40:45 +0200
branchENGINE-171
changeset 1886bb69022b91ef
parent 1885 da4e99a16e99
child 1887 3feebd18c35f
ENGINE-171: test for case changes and dot addresses
test/case_and_dot_address_test.cc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/case_and_dot_address_test.cc	Wed Jun 28 10:40:45 2017 +0200
     1.3 @@ -0,0 +1,80 @@
     1.4 +// This file is under GNU General Public License 3.0
     1.5 +// see LICENSE.txt
     1.6 +
     1.7 +#include <stdlib.h>
     1.8 +#include <string.h>
     1.9 +#include <time.h>
    1.10 +#include "platform.h"
    1.11 +#include <iostream>
    1.12 +#include <fstream>
    1.13 +#include <assert.h>
    1.14 +#include "mime.h"
    1.15 +#include "message_api.h"
    1.16 +#include "test_util.h"
    1.17 +
    1.18 +using namespace std;
    1.19 +
    1.20 +int main() {
    1.21 +    cout << "\n*** case_and_dot_address_test.cc ***\n\n";
    1.22 +
    1.23 +    PEP_SESSION session;
    1.24 +    
    1.25 +    cout << "calling init()\n";
    1.26 +    PEP_STATUS status = init(&session);   
    1.27 +    assert(status == PEP_STATUS_OK);
    1.28 +    assert(session);
    1.29 +    cout << "init() completed.\n";
    1.30 +    
    1.31 +    
    1.32 +    const string alice_pub_key = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
    1.33 +    const string alice_priv_key = slurp("test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc");
    1.34 +
    1.35 +    const char* alice_email_case = "pEp.teST.AlICe@pEP-pRoJeCt.ORG";
    1.36 +    const char* alice_email_dot = "pe.p.te.st.a.l.i.ce@pep-project.org";
    1.37 +    const char* alice_email_dotless = "peptestalice@pep-project.org";
    1.38 +    const char* alice_email_case_and_dot = "PE.p.teS.t.ALICE@pep-project.OrG";
    1.39 +
    1.40 +    PEP_STATUS statuspub = import_key(session, alice_pub_key.c_str(), alice_pub_key.length(), NULL);
    1.41 +    PEP_STATUS statuspriv = import_key(session, alice_priv_key.c_str(), alice_priv_key.length(), NULL);
    1.42 +    assert(statuspub == PEP_STATUS_OK);
    1.43 +    assert(statuspriv == PEP_STATUS_OK);
    1.44 +
    1.45 +    pEp_identity * alice_id = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
    1.46 +    status = update_identity(session, alice_id);
    1.47 +    assert(alice_id->fpr);
    1.48 +    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    1.49 +    free_identity(alice_id);
    1.50 +    alice_id = NULL;
    1.51 +
    1.52 +    alice_id = new_identity(alice_email_case, NULL, PEP_OWN_USERID, "Alice Test");
    1.53 +    status = update_identity(session, alice_id);
    1.54 +    assert(alice_id->fpr);
    1.55 +    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    1.56 +    free_identity(alice_id);
    1.57 +    alice_id = NULL;
    1.58 +
    1.59 +    alice_id = new_identity(alice_email_dot, NULL, PEP_OWN_USERID, "Alice Test");
    1.60 +    status = update_identity(session, alice_id);
    1.61 +    assert(alice_id->fpr);
    1.62 +    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    1.63 +    free_identity(alice_id);
    1.64 +    alice_id = NULL;
    1.65 +
    1.66 +    alice_id = new_identity(alice_email_dotless, NULL, PEP_OWN_USERID, "Alice Test");
    1.67 +    status = update_identity(session, alice_id);
    1.68 +    assert(alice_id->fpr);
    1.69 +    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    1.70 +    free_identity(alice_id);
    1.71 +    alice_id = NULL;
    1.72 +
    1.73 +    alice_id = new_identity(alice_email_case_and_dot, NULL, PEP_OWN_USERID, "Alice Test");
    1.74 +    status = update_identity(session, alice_id);
    1.75 +    assert(alice_id->fpr);
    1.76 +    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    1.77 +    free_identity(alice_id);
    1.78 +    alice_id = NULL;
    1.79 +    
    1.80 +    release(session);
    1.81 +
    1.82 +    return 0;
    1.83 +}