Fixed test. Need to go back and control tests for correctness, but at least we have something to work with for now. local_cpptest
authorKrista Bennett <krista@pep-project.org>
Tue, 08 May 2018 16:09:02 +0200
branchlocal_cpptest
changeset 26628179ef5e6b4c
parent 2661 2b0b15a718bc
child 2664 c68f27b7dd22
Fixed test. Need to go back and control tests for correctness, but at least we have something to work with for now.
test/src/engine_tests/ReencryptPlusExtraKeysTests.cc
     1.1 --- a/test/src/engine_tests/ReencryptPlusExtraKeysTests.cc	Tue May 08 15:43:07 2018 +0200
     1.2 +++ b/test/src/engine_tests/ReencryptPlusExtraKeysTests.cc	Tue May 08 16:09:02 2018 +0200
     1.3 @@ -114,45 +114,12 @@
     1.4      TEST_ASSERT(!(flags & PEP_decrypt_flag_src_modified));
     1.5      
     1.6      TEST_ASSERT(!modified_src);
     1.7 +    TEST_ASSERT(flags & PEP_decrypt_flag_src_modified == 0);
     1.8      //cout << modified_src << endl;
     1.9      
    1.10      free(decrypted_text);
    1.11      decrypted_text = nullptr;
    1.12  
    1.13 -    cout << "CHECK: Decrypting to see what keys it was encrypted for." << endl;
    1.14 -
    1.15 -    free(decrypted_text);
    1.16 -    decrypted_text = nullptr;
    1.17 -    flags = 0;
    1.18 -    char* throwaway = NULL;
    1.19 -
    1.20 -    status = MIME_decrypt_message(session,
    1.21 -                                  modified_src,
    1.22 -                                  strlen(modified_src),
    1.23 -                                  &decrypted_text,
    1.24 -                                  &keys,
    1.25 -                                  &rating,
    1.26 -                                  &flags,
    1.27 -                                  &throwaway);
    1.28 -
    1.29 -    
    1.30 -    cout << "keys used:\n";
    1.31 -    
    1.32 -    int i = 0;
    1.33 -    
    1.34 -    for (stringlist_t* kl = keys; kl && kl->value; kl = kl->next, i++)
    1.35 -    {
    1.36 -        if (i == 0) {
    1.37 -              cout << "Signed by " << (strcasecmp("", kl->value) == 0 ? "NOBODY" : kl->value) << endl;
    1.38 -              TEST_ASSERT(strcasecmp(fpr_own_recip_2_key,kl->value) == 0);
    1.39 -        }
    1.40 -        else {
    1.41 -            cout << "\t " << kl->value << endl;
    1.42 -            TEST_ASSERT(strcasecmp(fpr_own_recip_2_key, kl->value) == 0);
    1.43 -            cout << "Encrypted only for own identity! Yay! It worked!" << endl;
    1.44 -        }
    1.45 -        TEST_ASSERT(i < 2);
    1.46 -    }
    1.47      cout << "Case 1a: PASS" << endl << endl;
    1.48  
    1.49      cout << "Case 1b: Calling MIME_decrypt_message with reencrypt flag set on message sent from enigmail for recip 2 extra keys." << endl;
    1.50 @@ -188,7 +155,7 @@
    1.51      free(decrypted_text);
    1.52      decrypted_text = nullptr;
    1.53      flags = 0;
    1.54 -    throwaway = NULL;
    1.55 +    char* throwaway = NULL;
    1.56  
    1.57      status = MIME_decrypt_message(session,
    1.58                                    modified_src,
    1.59 @@ -205,7 +172,7 @@
    1.60      bool extra_key_0_found = false;
    1.61      bool extra_key_1_found = false;
    1.62      
    1.63 -    i = 0;
    1.64 +    int i = 0;
    1.65      
    1.66      for (stringlist_t* kl = keys; kl && kl->value; kl = kl->next, i++)
    1.67      {
    1.68 @@ -240,7 +207,10 @@
    1.69      cout << "Case 1b: PASS" << endl << endl;
    1.70  
    1.71      cout << "Case 2a: Calling MIME_decrypt_message with reencrypt flag set on message sent with recip 2 in BCC from enigmail with no extra keys." << endl;
    1.72 -
    1.73 +    
    1.74 +    free(modified_src);
    1.75 +    modified_src = NULL;
    1.76 +    
    1.77      free_stringlist(keys);
    1.78      keys = NULL;
    1.79  
    1.80 @@ -265,39 +235,8 @@
    1.81      free(decrypted_text);
    1.82      decrypted_text = nullptr;
    1.83  
    1.84 -    cout << "CHECK: Decrypting to see what keys it was encrypted for." << endl;
    1.85 -
    1.86 -    free(decrypted_text);
    1.87 -    decrypted_text = nullptr;
    1.88 -    flags = 0;
    1.89 -    throwaway = NULL;
    1.90 -
    1.91 -    status = MIME_decrypt_message(session,
    1.92 -                                  modified_src,
    1.93 -                                  strlen(modified_src),
    1.94 -                                  &decrypted_text,
    1.95 -                                  &keys,
    1.96 -                                  &rating,
    1.97 -                                  &flags,
    1.98 -                                  &throwaway);
    1.99 -    
   1.100 -    cout << "keys used:\n";
   1.101 -        
   1.102 -    i = 0;
   1.103 -    
   1.104 -    for (stringlist_t* kl = keys; kl && kl->value; kl = kl->next, i++)
   1.105 -    {
   1.106 -        if (i == 0) {
   1.107 -              cout << "Signed by " << (strcasecmp("", kl->value) == 0 ? "NOBODY" : kl->value) << endl;
   1.108 -//              TEST_ASSERT(strcasecmp(fpr_own_recip_2_key,kl->value) == 0);
   1.109 -        }
   1.110 -        else {
   1.111 -            cout << "\t " << kl->value << endl;
   1.112 -//            TEST_ASSERT(strcasecmp(fpr_own_recip_2_key, kl->value) == 0);
   1.113 -            cout << "Encrypted only for own identity! Yay! It worked!" << endl;
   1.114 -        }
   1.115 -        TEST_ASSERT(i < 2);
   1.116 -    }
   1.117 +    TEST_ASSERT(!modified_src);
   1.118 +    TEST_ASSERT(flags & PEP_decrypt_flag_src_modified == 0);
   1.119  
   1.120      cout << "Case 2a: PASS" << endl << endl;
   1.121  
   1.122 @@ -385,6 +324,9 @@
   1.123      cout << "Case 2b: PASS" << endl << endl;
   1.124  
   1.125      cout << "Case 3a: Calling MIME_decrypt_message with reencrypt flag set on message generated by pEp (message 2.0) with no extra keys." << endl;
   1.126 +    free(modified_src);
   1.127 +    modified_src = NULL;
   1.128 +    
   1.129      free_stringlist(keys);
   1.130      keys = NULL;
   1.131  
   1.132 @@ -408,44 +350,12 @@
   1.133  
   1.134      TEST_ASSERT(decrypted_text);
   1.135      TEST_ASSERT(rating);
   1.136 +    TEST_ASSERT(!modified_src);
   1.137 +    TEST_ASSERT(flags & PEP_decrypt_flag_src_modified == 0);
   1.138  
   1.139      free(decrypted_text);
   1.140      decrypted_text = nullptr;
   1.141  
   1.142 -    cout << "CHECK: Decrypting to see what keys it was encrypted for." << endl;
   1.143 -
   1.144 -    free(decrypted_text);
   1.145 -    decrypted_text = nullptr;
   1.146 -    flags = 0;
   1.147 -    throwaway = NULL;
   1.148 -
   1.149 -    status = MIME_decrypt_message(session,
   1.150 -                                  modified_src,
   1.151 -                                  strlen(modified_src),
   1.152 -                                  &decrypted_text,
   1.153 -                                  &keys,
   1.154 -                                  &rating,
   1.155 -                                  &flags,
   1.156 -                                  &throwaway);
   1.157 -    
   1.158 -    cout << "keys used:\n";
   1.159 -      
   1.160 -    i = 0;
   1.161 -
   1.162 -    for (stringlist_t* kl = keys; kl && kl->value; kl = kl->next, i++)
   1.163 -    {
   1.164 -        if (i == 0) {
   1.165 -            cout << "Signed by " << (strcasecmp("", kl->value) == 0 ? "NOBODY" : kl->value) << endl;
   1.166 -//            TEST_ASSERT(strcasecmp(fpr_own_recip_key,kl->value) == 0);
   1.167 -        }
   1.168 -        else {
   1.169 -            cout << "\t " << kl->value << endl;
   1.170 -//            TEST_ASSERT(strcasecmp(fpr_own_recip_key, kl->value) == 0);
   1.171 -            cout << "Encrypted only for own identity! Yay! It worked!" << endl;
   1.172 -        }
   1.173 -        TEST_ASSERT(i < 2);
   1.174 -    }
   1.175 -
   1.176      cout << "Case 3a: PASS" << endl << endl;
   1.177  
   1.178