ENGINE-420: test mods and a mime.c fix for disappearing usernames in mime_encode ENGINE-420
authorKrista Bennett <krista@pep-project.org>
Fri, 13 Apr 2018 14:46:44 +0200
branchENGINE-420
changeset 2597d8a4f5d437ae
parent 2596 535f40a7121b
child 2598 eaf109aa1e6c
ENGINE-420: test mods and a mime.c fix for disappearing usernames in mime_encode
src/mime.c
test/encrypt_attach_private_key_test.cc
test/test_keys/priv/priv-key-import-test-main_0-0xC065A213_priv.asc
test/test_keys/pub/priv-key-import-test-main_0-0xC065A213_pub.asc
     1.1 --- a/src/mime.c	Fri Apr 13 12:34:08 2018 +0200
     1.2 +++ b/src/mime.c	Fri Apr 13 14:46:44 2018 +0200
     1.3 @@ -304,7 +304,7 @@
     1.4  
     1.5      _username = (ident->username && must_field_value_be_encoded(ident->username))
     1.6                    ? mailmime_encode_subject_header("utf-8", ident->username, 0) 
     1.7 -                  : strdup("");
     1.8 +                  : strdup(ident->username);
     1.9                    
    1.10      assert(_username);
    1.11      if (_username == NULL)
     2.1 --- a/test/encrypt_attach_private_key_test.cc	Fri Apr 13 12:34:08 2018 +0200
     2.2 +++ b/test/encrypt_attach_private_key_test.cc	Fri Apr 13 14:46:44 2018 +0200
     2.3 @@ -37,6 +37,7 @@
     2.4      const char* fpr_main_me = "8AB616A3BD51DEF714B5E688EFFB540C3276D2E5";
     2.5      pEp_identity* same_addr_same_uid = NULL;
     2.6      const char* fpr_same_addr_same_uid = "359DD8AC87D1F5E4304D08338D7185F180C8CD87";
     2.7 +    
     2.8      pEp_identity* same_addr_diff_uid = NULL;
     2.9      const char* fpr_same_addr_diff_uid = "B044B83639E292283A3F6E14C2E64B520B74809C";
    2.10  
    2.11 @@ -99,7 +100,7 @@
    2.12      // Identity with same address and user_id - the fpr here will be ignored in update_identity and friends.
    2.13      same_addr_same_uid = new_identity(main_addr, fpr_same_addr_same_uid, own_uid, "PrivateKey Import Test");
    2.14      status = key_reset_trust(session, same_addr_same_uid);
    2.15 -    assert(status == PEP_STATUS_OK);
    2.16 +    assert(status == PEP_STATUS_OK || status == PEP_CANNOT_FIND_IDENTITY);
    2.17      assert(strcmp(same_addr_same_uid->fpr, fpr_same_addr_same_uid) == 0);
    2.18      
    2.19      // Identity with same address and different user_id
    2.20 @@ -107,7 +108,7 @@
    2.21      same_addr_diff_uid = new_identity(main_addr, fpr_same_addr_diff_uid, diff_uid_0, "PrivateKey Import Test");
    2.22      assert(same_addr_diff_uid);
    2.23      status = key_reset_trust(session, same_addr_diff_uid);
    2.24 -    assert(status == PEP_STATUS_OK);
    2.25 +    assert(status == PEP_STATUS_OK || status == PEP_CANNOT_FIND_IDENTITY);
    2.26      assert(strcmp(same_addr_diff_uid->fpr, fpr_same_addr_diff_uid) == 0);
    2.27      
    2.28      // Identity with diff address and same user_id
    2.29 @@ -115,7 +116,7 @@
    2.30      diff_addr_same_uid = new_identity(diff_addr_0, fpr_diff_addr_same_uid, own_uid, "PrivateKey Import Test");
    2.31      assert(diff_addr_same_uid);
    2.32      status = key_reset_trust(session, diff_addr_same_uid);
    2.33 -    assert(status == PEP_STATUS_OK);
    2.34 +    assert(status == PEP_STATUS_OK || status == PEP_CANNOT_FIND_IDENTITY);
    2.35      assert(strcmp(diff_addr_same_uid->fpr, fpr_diff_addr_same_uid) == 0);
    2.36  
    2.37      // Identity with different address and different user_id
    2.38 @@ -123,7 +124,7 @@
    2.39      diff_addr_diff_uid = new_identity(diff_addr_1, fpr_diff_addr_diff_uid, diff_uid_1, "PrivateKey Import Test");
    2.40      assert(diff_addr_diff_uid);
    2.41      status = key_reset_trust(session, diff_addr_diff_uid);
    2.42 -    assert(status == PEP_STATUS_OK);
    2.43 +    assert(status == PEP_STATUS_OK || status == PEP_CANNOT_FIND_IDENTITY);
    2.44      assert(strcmp(diff_addr_diff_uid->fpr, fpr_diff_addr_diff_uid) == 0);
    2.45      cout << "Done!" << endl << endl;
    2.46  
    2.47 @@ -283,6 +284,7 @@
    2.48      mime_encode_message(enc_same_addr_same_uid_trusted, false, &encrypted_msg_text);                                    
    2.49      cout << encrypted_msg_text << endl << endl;
    2.50      
    2.51 +    // FIXME: Free all the damned things
    2.52        
    2.53      release(session);
    2.54      
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/test_keys/priv/priv-key-import-test-main_0-0xC065A213_priv.asc	Fri Apr 13 14:46:44 2018 +0200
     3.3 @@ -0,0 +1,63 @@
     3.4 +-----BEGIN PGP PRIVATE KEY BLOCK-----
     3.5 +
     3.6 +lQOYBFrQoQUBCADZri/DgdFOns76UcS+fWryl/wOWTeWOTT5PntcYf+XcU+vNe0R
     3.7 +O7G0xZMP9udyj1amV7cydlxafX1CIL1KNXlQGg5vXNd3Kdw9Jp5EfLjrr36g8+1P
     3.8 +jlXemFRKpqpcOQd/IEj/wrF9kQRAl/UIyLY7uGl9SA9KSgVn3rUhuCH++sLZuPkg
     3.9 +uIaAGstGbe/0Ua1+OEdWFVefTvti9T6aA01KEN3pVmWmqS0xPWa+2EYCoWGc4ONW
    3.10 +KG2nT0CP2Fyk3an/nbCtKhUjE5aneFHlFHb+vf+fChejq1VwbjIAGEKwI48JFlqy
    3.11 +q67T6srlly12U40OsiMOL583RCIXzx0GN01HABEBAAEAB/9Qkpr3YNvaoAm4uf97
    3.12 +Cu1FMmCH5xoeLrqe7zO2NEfpBHYcQneng1L5uJAAvsFYtBm8pIcY1JrGm+B7U6b9
    3.13 +CuIGdj6VleXjI8lzkRHQA+JmyqSyateSNPsv026P2zT/wdQ2h/q9QJF2CvFp/1Uh
    3.14 +lTluzYmuZ7fRJajuk460FnXu7K/kMThI/myeuA7kNKU2cGnj6HdJ/qDalt7rU8OM
    3.15 +Zj95HwNj9R7JIm4oEev6W4AN5ujioAHD3n2942MSBG6QKOTBVBcGktoVfJPu1GV9
    3.16 +UPwJOgD7PfzTkZlsh1ckBVO6dV1ccmlXfH23Y804WfTlZRp2XSFfWYfYiNO++8Fu
    3.17 +FtRhBADqjiWtxcuLaKM2a9Vq09d+Ps8AZnXNURYQvyQR8T6U7YNC+KpoMwAZDTdW
    3.18 +mhSOJPV2L+Gvph0qYhgfsVkK4oTs1RbyLGI67k52o3y60IWS8A9dJ4W9X4XlGnjt
    3.19 +ay8gpokr4Hk90wCC6j+ZFLCnG0vZqAMa7VZRlw4vGJoHD3UwqQQA7ZUTznHsmuBf
    3.20 +RV0/4Q4Y9v7ilZLh49ODLJhu+mHKJVc6rDHoDRbHgCMYG8qac2cmE0z9d5E50+M/
    3.21 +mmKbmIs+UzsFzRoJK3vD3WOHNLTLEnfa6euMy2FaYmd35i3oBFfP33pBffF79wAL
    3.22 +8KiowRSedzCn0O4Opc7OgOspWKQKFG8EAMAsMhtzzHrinJ3APnZ4hWiK6Ki/W12e
    3.23 +B9OFpUU6r7hEgh+5dL3/L+DIVn/q+9Y0IFuBgszG56FiXBGTMJXbYNJRgZDheU2D
    3.24 +e39JhzCpgDprfRKv3fHYp5qVLH2dXEGKAST1Awc+vabRumuBoHf8ulyPMbnGUSKv
    3.25 +knP1mmQraHvRRMG0SVByaXZLZXkgUmVjaXBpZW50IFN0cmlrZXMgQmFjayA8cHJp
    3.26 +di1rZXktaW1wb3J0LXRlc3QtbWFpbkBkYXJ0aG1hbWEuY29vbD6JATcEEwEKACIF
    3.27 +AlrQoQUCGy8GCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEFG8p4PAZaIT8XkH
    3.28 +9RKpLdjYSxjRJYL+aWdbiaUHPgTISqpmXQfQiHZJL7nzORrQY3l08bN+4ZbzBJLa
    3.29 +xmrfwlsUhbttwXuD9HzBGcpkfERlyin52jUDBJULvU4DDfFP0pRNVPvVG3Wa7eff
    3.30 +6PE5akGoDgbEjv344FDbfLYYdcUDL65VYiL7zUBRxN0Xas9r7UZa1xSm9+juWNmJ
    3.31 +4b9oTMnbWwSY8bx/AQBq3kWRPM0pguFk6eGyq9AKLGUbvywc5VSHOA3Lu67vD6bA
    3.32 +aDubdw+PTsuFdlOP25gtZRIy/5ioeQn0FNwv7q5/R9UeGtC8h8EBF1a8ivBFRh/a
    3.33 +MTcBJLVIiQz9ou7xlfYoep0DmARa0KEFAQgA34g3wG+pq0ek1EVZuBFAGNGASXAD
    3.34 +L4uDOFJAy7HmRqrW1qJz7ZvJcOCN6g5LJQ1pFPJAsaN2VBB7hNNF9z0lQDp2Y8iP
    3.35 +Z3D9ls2Y1KIEibV1mrgXmAac4mF391HFyzUtuEV6I0XVSZsHy73VR4DX+r/AUFYa
    3.36 +C9jYwTHlIjgqXEAO+SAncwHyfDUUtLEECYfcvsAUk+8bLyZgo/OL3W71Xed+5stc
    3.37 +Ra7NvmKnkY0UysYq2VheG82e04wnWWsLkwTPvRXc92VnOTMo7RdJ6X80RumY+YT4
    3.38 +Sju4WGHc4NVBolXLqvn5n8xYjwPokg2t0sbXJvlxjlfuoiVKtBcYY6mLXwARAQAB
    3.39 +AAf+JTmoHzH5TX7W4krSUCb/R6LL/G7c+PQA3EZGaCWuNaKJuKDBMZa6C0Q6HfpX
    3.40 +ZUpAb66QO4T/VayRBWOxySSzqWiTArcJuq5EbPK8OtzoaI6BkUyLEVQ4mDKnKdbC
    3.41 +W771aDSZzHn6tRFOUQ3CEPBSB34bZsWP/N0V68aFZBd6ZnYs20SRIE7hB12mCpms
    3.42 +azHKmX/S2v1gOZ1bjuEoKAgI8JLhPuaR7Cw5+jL7z/8EvQZjzfo06icxyhH0R43b
    3.43 +lFSmkp2pu0iEajK6m96Dk/a/E29WriFpBmMMFQ5KngH+MwQXC30YWLxtsx5GvMu4
    3.44 +CUme/c/r98Z8bFclyV2bXDZcsQQA7un99/AdRRnI4kiKTbk3SHelg1DSh6prkEkF
    3.45 +U41W1VYpqvn7q8FTCx3q8YeEHBXZ9Vfumf7kWWFjre6IDF/qAIgJFS2+fTOWuL65
    3.46 +MuvyQPidWEQWv7WybrNrAcUoAy5EdoGT6QwB6XDyVSNtg8u1dYj9J7IwtGeOzTzS
    3.47 +UcEjpwsEAO+EnYIycE25hdMvUBCZcixWPxqOHmya4d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23ybAKERW/z/CQL5by3RU
    3.63 +4ahLXsRIFTQXR5Jf1gwX9WnoJDAKDavwaBVuSEK7gJDLj41ITf3Oi0JmOb0sQb6Y
    3.64 +4bhg7xfj/7Tg5HAey2fWmMZIfAqdxW+DJtJJ8g==
    3.65 +=lesn
    3.66 +-----END PGP PRIVATE KEY BLOCK-----
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/test_keys/pub/priv-key-import-test-main_0-0xC065A213_pub.asc	Fri Apr 13 14:46:44 2018 +0200
     4.3 @@ -0,0 +1,36 @@
     4.4 +-----BEGIN PGP PUBLIC KEY BLOCK-----
     4.5 +
     4.6 +mQENBFrQoQUBCADZri/DgdFOns76UcS+fWryl/wOWTeWOTT5PntcYf+XcU+vNe0R
     4.7 +O7G0xZMP9udyj1amV7cydlxafX1CIL1KNXlQGg5vXNd3Kdw9Jp5EfLjrr36g8+1P
     4.8 +jlXemFRKpqpcOQd/IEj/wrF9kQRAl/UIyLY7uGl9SA9KSgVn3rUhuCH++sLZuPkg
     4.9 +uIaAGstGbe/0Ua1+OEdWFVefTvti9T6aA01KEN3pVmWmqS0xPWa+2EYCoWGc4ONW
    4.10 +KG2nT0CP2Fyk3an/nbCtKhUjE5aneFHlFHb+vf+fChejq1VwbjIAGEKwI48JFlqy
    4.11 +q67T6srlly12U40OsiMOL583RCIXzx0GN01HABEBAAG0SVByaXZLZXkgUmVjaXBp
    4.12 +ZW50IFN0cmlrZXMgQmFjayA8cHJpdi1rZXktaW1wb3J0LXRlc3QtbWFpbkBkYXJ0
    4.13 +aG1hbWEuY29vbD6JATcEEwEKACIFAlrQoQUCGy8GCwkIBwMCBhUIAgkKCwQWAgMB
    4.14 +Ah4BAheAAAoJEFG8p4PAZaIT8XkH9RKpLdjYSxjRJYL+aWdbiaUHPgTISqpmXQfQ
    4.15 +iHZJL7nzORrQY3l08bN+4ZbzBJLaxmrfwlsUhbttwXuD9HzBGcpkfERlyin52jUD
    4.16 +BJULv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+Je2JMvHF9kDBhYMZtE2D7GKGnw6gEXSfWrpJri+5fWz4YzbEVz8jLhP8E4WII/5+
    4.32 +X6+V6wgAiny3ryx29MMBce8U0XAPqRiG5wdindm3UfZBNUrqPF2MwFEGgWYomVYj
    4.33 +DAfeo2kYXdNh3AhP0f8ucGWdXTmYstcuTrd9Gd9zMoez/xmvmkpPO5i3V3l+jhP9
    4.34 +5PzPM+QEh+Qe0C/O5RcXaYBXEOO6V2AwiEi1hy8iXoGmaf+WQ2oyyDECbe6x2N11
    4.35 +Qg088v29VbD26c2cLMs+jsPecJZrjN3SgYg23ybAKERW/z/CQL5by3RU4ahLXsRI
    4.36 +FTQXR5Jf1gwX9WnoJDAKDavwaBVuSEK7gJDLj41ITf3Oi0JmOb0sQb6Y4bhg7xfj
    4.37 +/7Tg5HAey2fWmMZIfAqdxW+DJtJJ8g==
    4.38 +=BQYW
    4.39 +-----END PGP PUBLIC KEY BLOCK-----