test/case_and_dot_address_test.cc
author Krista Bennett <krista@pep-project.org>
Wed, 07 Feb 2018 16:16:40 +0100
branchENGINE-250
changeset 2482 c713df1942dd
parent 2481 dd1eaa8cc1eb
permissions -rw-r--r--
Probably own identity issues.
     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     char* user_id = get_new_uuid();
    29     
    30     const string alice_pub_key = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.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     assert(statuspub == PEP_STATUS_OK);
    39 
    40     pEp_identity * alice_id = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", user_id, "Alice Test");
    41 
    42     status = trust_personal_key(session, alice_id);
    43 
    44     pEp_identity * new_alice_id = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", user_id, "Alice Test");
    45     status = update_identity(session, new_alice_id);
    46     assert(new_alice_id->fpr);
    47     assert(strcmp(new_alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    48     free_identity(new_alice_id);
    49     free_identity(alice_id);
    50     alice_id = NULL;
    51     new_alice_id = NULL;
    52 
    53     alice_id = new_identity(alice_email_case, NULL, user_id, "Alice Test");
    54     status = update_identity(session, alice_id);
    55     assert(alice_id->fpr);
    56     cout << "Alice email: " << alice_email_case << " Alice fpr (should be 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97): " << alice_id->fpr << endl;
    57     assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    58     free_identity(alice_id);
    59     alice_id = NULL;
    60 
    61     alice_id = new_identity(alice_email_dot, NULL, user_id, "Alice Test");
    62     status = update_identity(session, alice_id);
    63     assert(alice_id->fpr);
    64     cout << "Alice email: " << alice_email_dot << " Alice fpr (should be 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97): " << alice_id->fpr << endl;
    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, user_id, "Alice Test");
    70     status = update_identity(session, alice_id);
    71     assert(alice_id->fpr);
    72     cout << "Alice email: " << alice_email_dotless << " Alice fpr (should be 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97): " << alice_id->fpr << endl;
    73     assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    74     free_identity(alice_id);
    75     alice_id = NULL;
    76 
    77     alice_id = new_identity(alice_email_case_and_dot, NULL, user_id, "Alice Test");
    78     status = update_identity(session, alice_id);
    79     assert(alice_id->fpr);
    80     cout << "Alice email: " << alice_email_case_and_dot << " Alice fpr (should be 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97): " << alice_id->fpr << endl;
    81     assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
    82     free_identity(alice_id);
    83     alice_id = NULL;
    84     
    85     release(session);
    86 
    87     return 0;
    88 }