ENGINE-323 fixed
authorVolker Birk <vb@pep.foundation>
Sat, 30 Dec 2017 16:54:37 +0100
changeset 23405c5ef77d15da
parent 2339 883a96c0448f
child 2341 96e39a8ae77d
ENGINE-323 fixed
src/message_api.c
test/message_api_test.cc
     1.1 --- a/src/message_api.c	Sat Dec 30 16:54:29 2017 +0100
     1.2 +++ b/src/message_api.c	Sat Dec 30 16:54:37 2017 +0100
     1.3 @@ -1528,7 +1528,7 @@
     1.4          }
     1.5      }
     1.6  
     1.7 -    if (!dest_keys_found ||
     1.8 +    if (enc_format == PEP_enc_none || !dest_keys_found ||
     1.9          stringlist_length(keys)  == 0 ||
    1.10          _rating(max_comm_type,
    1.11                  PEP_rating_undefined) < PEP_rating_reliable)
    1.12 @@ -1577,10 +1577,6 @@
    1.13                  // TODO: implement
    1.14                  NOT_IMPLEMENTED */
    1.15  
    1.16 -            case PEP_enc_none:
    1.17 -                status = PEP_UNENCRYPTED;
    1.18 -                break;
    1.19 -
    1.20              default:
    1.21                  assert(0);
    1.22                  status = PEP_ILLEGAL_VALUE;
     2.1 --- a/test/message_api_test.cc	Sat Dec 30 16:54:29 2017 +0100
     2.2 +++ b/test/message_api_test.cc	Sat Dec 30 16:54:37 2017 +0100
     2.3 @@ -145,7 +145,7 @@
     2.4  	PEP_STATUS status2 = MIME_decrypt_message(session, mimetext.c_str(), mimetext.length(),
     2.5  		&plaintext, &keys_used, &rating, &dec_flags);
     2.6  	
     2.7 -	std::cout << "MIME_decrypt_message returned " << status2 << std::hex << " (0x" << status2 << ")" << endl;
     2.8 +	std::cout << "MIME_decrypt_message returned " << std::dec << status2 << std::hex << " (0x" << status2 << ")" << std::dec << endl;
     2.9  	
    2.10  	assert(status2 == PEP_DECRYPTED);
    2.11  	assert(plaintext);
    2.12 @@ -321,14 +321,35 @@
    2.13      
    2.14      cout << dec_msg << endl;
    2.15      
    2.16 +    cout << "\nTesting encrypt_message() with enc_format = PEP_enc_none\n\n";
    2.17 +
    2.18 +    message *msg7 = new_message(PEP_dir_outgoing);
    2.19 +    pEp_identity * me7 = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
    2.20 +    identity_list *to7 = new_identity_list(new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test"));
    2.21 +    msg7->from = me7;
    2.22 +    msg7->to = to7;
    2.23 +    msg7->shortmsg = strdup("My Subject");
    2.24 +    msg7->longmsg = strdup("This is some text.\n");
    2.25 +
    2.26 +    message *enc7 = nullptr;
    2.27 +    PEP_STATUS status9 = encrypt_message(session, msg7, NULL, &enc7, PEP_enc_none, 0);
    2.28 +	std::cout << "encrypt_message returned " << std::dec << status9 << std::hex << " (0x" << status9 << ")" << std::dec << endl;
    2.29 +    assert(status9 == PEP_UNENCRYPTED);
    2.30 +    assert(enc7 == nullptr);
    2.31 +    assert(msg7->shortmsg && msg7->longmsg);
    2.32 +    cout << msg7->shortmsg << "\n";
    2.33 +    cout << msg7->longmsg << "\n";
    2.34 +    assert(strcmp(msg7->shortmsg, "My Subject") == 0);
    2.35 +    assert(strcmp(msg7->longmsg, "This is some text.\n") == 0);
    2.36      
    2.37 -    cout << "freeing messages…\n";
    2.38 +    cout << "\nfreeing messages…\n";
    2.39 +    free_message(msg7);
    2.40 +    free_message(msg6);
    2.41 +    free_message(msg5);
    2.42      free_message(msg4);
    2.43      free_message(msg3);
    2.44      free_message(msg2);
    2.45      free_message(enc_msg2);
    2.46 -    free_message(msg6);
    2.47 -    free_message(msg5);
    2.48      cout << "done.\n";
    2.49  
    2.50      free(enc_msg);