Merge remote-tracking branch 'origin/tizen' into yaca 02/84602/1
authorZbigniew Jasinski <z.jasinski@samsung.com>
Fri, 19 Aug 2016 10:56:31 +0000 (12:56 +0200)
committerZbigniew Jasinski <z.jasinski@samsung.com>
Fri, 19 Aug 2016 10:56:45 +0000 (12:56 +0200)
Change-Id: Ie127f8356cce6938c6c9b9b9ad5c109db4c79117
Signed-off-by: Zbigniew Jasinski <z.jasinski@samsung.com>
src/libwebappenc-tests/test_cases.cpp

index 052fb37..4f242aa 100644 (file)
 #define DOWNLOADED_ENC_FILE "/tmp/downloaded_enc_file"
 #define PRELOADED_ENC_FILE "/tmp/preloaded_enc_file"
 
+namespace {
+
+const uid_t DEFAULT_UID = 5001;
+
 int _read_from_file(const char* path, unsigned char** data, size_t* len)
 {
     int ret = WAE_ERROR_NONE;
@@ -110,12 +114,14 @@ error:
     return ret;
 }
 
+} // namespace anonymous
+
 
 RUNNER_TEST_GROUP_INIT(libwebappenc)
 
 RUNNER_TEST(T01_init) {
-    wae_remove_app_dek(TEST_PKGID_1, WAE_DOWNLOADED_GLOBAL_APP);
-    wae_remove_app_dek(TEST_PKGID_2, WAE_PRELOADED_APP);
+    wae_remove_app_dek(DEFAULT_UID, TEST_PKGID_1);
+    wae_remove_global_app_dek(TEST_PKGID_2, true);
 }
 
 RUNNER_CHILD_TEST(T02_downloaded_web_app_enc){
@@ -126,9 +132,7 @@ RUNNER_CHILD_TEST(T02_downloaded_web_app_enc){
     unsigned char* encrypted = NULL;
     size_t encLen = 0;
 
-    wae_app_type_e appType = WAE_DOWNLOADED_GLOBAL_APP;
-
-    ret = wae_encrypt_web_application(pkgId, appType,
+    ret = wae_encrypt_web_application(DEFAULT_UID, pkgId,
                                       (const unsigned char*)plaintext, plaintextLen,
                                       &encrypted, &encLen);
     RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_encrypt_web_application. ret=" << ret);
@@ -147,12 +151,10 @@ RUNNER_CHILD_TEST(T03_downloaded_web_app_dec){
     unsigned char* decrypted = NULL;
     size_t decLen = 0;
 
-    wae_app_type_e appType = WAE_DOWNLOADED_GLOBAL_APP;
-
     ret = _read_from_file(DOWNLOADED_ENC_FILE, &encrypted, &encLen);
     RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: _read_from_file. ret=" << ret);
 
-    ret = wae_decrypt_web_application(pkgId, appType, encrypted, encLen, &decrypted, &decLen);
+    ret = wae_decrypt_web_application(DEFAULT_UID, pkgId, encrypted, encLen, &decrypted, &decLen);
     RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_decrypt_web_application. ret=" << ret);
 
     RUNNER_ASSERT_MSG(plaintextLen == decLen,
@@ -170,12 +172,10 @@ RUNNER_CHILD_TEST(T04_preloaded_web_app_enc){
     unsigned char* encrypted = NULL;
     size_t encLen = 0;
 
-    wae_app_type_e appType = WAE_PRELOADED_APP;
-
-    ret = wae_encrypt_web_application(pkgId, appType,
+    ret = wae_encrypt_global_web_application(pkgId, true,
                                       (const unsigned char*)plaintext, plaintextLen,
                                       &encrypted, &encLen);
-    RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_encrypt_web_application. ret=" << ret);
+    RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_encrypt_global_web_application. ret=" << ret);
 
     ret = _write_to_file(PRELOADED_ENC_FILE, encrypted, encLen);
     RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: _write_to_file. file=" << DOWNLOADED_ENC_FILE);
@@ -196,13 +196,11 @@ RUNNER_CHILD_TEST(T06_preloaded_web_app_dec){
     unsigned char* decrypted = NULL;
     size_t decLen = 0;
 
-    wae_app_type_e appType = WAE_PRELOADED_APP;
-
     ret = _read_from_file(PRELOADED_ENC_FILE, &encrypted, &encLen);
     RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: _read_from_file. ret=" << ret);
 
-    ret = wae_decrypt_web_application(pkgId, appType, encrypted, encLen, &decrypted, &decLen);
-    RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_decrypt_web_application. ret=" << ret);
+    ret = wae_decrypt_global_web_application(pkgId, true, encrypted, encLen, &decrypted, &decLen);
+    RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_decrypt_global_web_application. ret=" << ret);
 
     RUNNER_ASSERT_MSG(plaintextLen == decLen,
                       "FAIL: plaintext_len("<<plaintextLen<<") != decrypted_len(" <<decLen<<")");
@@ -214,9 +212,9 @@ RUNNER_CHILD_TEST(T06_preloaded_web_app_dec){
 RUNNER_CHILD_TEST(T07_remove_app_dek) {
     int ret = WAE_ERROR_NONE;
 
-    ret = wae_remove_app_dek(TEST_PKGID_1, WAE_DOWNLOADED_GLOBAL_APP);
+    ret = wae_remove_app_dek(DEFAULT_UID, TEST_PKGID_1);
     RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_remove_app_dek. ret=" << ret);
 
-    ret = wae_remove_app_dek(TEST_PKGID_2, WAE_PRELOADED_APP);
-    RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_remove_app_dek. ret=" << ret);
+    ret = wae_remove_global_app_dek(TEST_PKGID_2, true);
+    RUNNER_ASSERT_MSG(ret == WAE_ERROR_NONE, "FAIL: wae_remove_global_app_dek. ret=" << ret);
 }