test/case_and_dot_address_test.cc
author Krista Bennett <krista@pep-project.org>
Mon, 29 Jan 2018 12:15:51 +0100
changeset 2461 85c8e5aad3bc
parent 2308 b7ef1c9005ae
child 2481 dd1eaa8cc1eb
permissions -rw-r--r--
Urgh. Fixing bad merge (???)
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #include <stdlib.h>
     5 #include <string.h>
     6 #include <time.h>
     7 #include "platform.h"
     8 #include <iostream>
     9 #include <fstream>
    10 #include <assert.h>
    11 #include "mime.h"
    12 #include "message_api.h"
    13 #include "test_util.h"
    14 
    15 using namespace std;
    16 
    17 int main() {
    18     cout << "\n*** case_and_dot_address_test.cc ***\n\n";
    19 
    20     PEP_SESSION session;
    21     
    22     cout << "calling init()\n";
    23     PEP_STATUS status = init(&session);   
    24     assert(status == PEP_STATUS_OK);
    25     assert(session);
    26     cout << "init() completed.\n";
    27     
    28     
    29     const string alice_pub_key = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
    30     const string alice_priv_key = slurp("test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc");
    31 
    32     const char* alice_email_case = "pEp.teST.AlICe@pEP-pRoJeCt.ORG";
    33     const char* alice_email_dot = "pe.p.te.st.a.l.i.ce@pep-project.org";
    34     const char* alice_email_dotless = "peptestalice@pep-project.org";
    35     const char* alice_email_case_and_dot = "PE.p.teS.t.ALICE@pep-project.OrG";
    36 
    37     PEP_STATUS statuspub = import_key(session, alice_pub_key.c_str(), alice_pub_key.length(), NULL);
    38     PEP_STATUS statuspriv = import_key(session, alice_priv_key.c_str(), alice_priv_key.length(), NULL);
    39     assert(statuspub == PEP_STATUS_OK);
    40     assert(statuspriv == PEP_STATUS_OK);
    41 
    42     pEp_identity * alice_id = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", PEP_OWN_USERID, "Alice Test");
    43     identity_list* own_id = new_identity_list(alice_id);
    44     status = initialise_own_identities(session, own_id);
    45     status = trust_personal_key(session, alice_id);
    46     pEp_identity * new_alice_id = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", PEP_OWN_USERID, "Alice Test");
    47     status = update_identity(session, new_alice_id);
    48     assert(new_alice_id->fpr);
    49     assert(strcmp(new_alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    50     free_identity(new_alice_id);
    51     free_identity(alice_id);
    52     alice_id = NULL;
    53     new_alice_id = NULL;
    54 
    55     alice_id = new_identity(alice_email_case, NULL, PEP_OWN_USERID, "Alice Test");
    56     status = myself(session, alice_id);
    57     assert(alice_id->fpr);
    58     assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    59     free_identity(alice_id);
    60     alice_id = NULL;
    61 
    62     alice_id = new_identity(alice_email_dot, NULL, PEP_OWN_USERID, "Alice Test");
    63     status = myself(session, alice_id);
    64     assert(alice_id->fpr);
    65     assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    66     free_identity(alice_id);
    67     alice_id = NULL;
    68 
    69     alice_id = new_identity(alice_email_dotless, NULL, PEP_OWN_USERID, "Alice Test");
    70     status = myself(session, alice_id);
    71     assert(alice_id->fpr);
    72     assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    73     free_identity(alice_id);
    74     alice_id = NULL;
    75 
    76     alice_id = new_identity(alice_email_case_and_dot, NULL, PEP_OWN_USERID, "Alice Test");
    77     status = myself(session, alice_id);
    78     assert(alice_id->fpr);
    79     assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    80     free_identity(alice_id);
    81     alice_id = NULL;
    82     
    83     release(session);
    84 
    85     return 0;
    86 }