Skip to content

Commit

Permalink
[GLib] In new API, update hsts directories for TestWebsiteData.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259515

Reviewed by Michael Catanzaro.

As mentioned in 260511@main and 261018@main, A GLib-specific bug in the
defaultHSTSStorageDirectory is fixed, but only for the new API versions.
The HSTS database goes under the base cache directory if provided, but
if not provided it goes under the base data directory; leave it broken in
the original API versions to avoid leaking the HSTS database on disk.
Also, move it to a subdirectory in the new API version.

Updating the directories (to baseCacheDirectory for old API and
under subdirectory for new API, using code that we previously had before
259132@main) in prepopulateHstsData fixes the hsts test in
TestWebsiteData, which were marked as failing under a meta-gardening bug
in webkit.org/b/256557.

* Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp:
(prepopulateHstsData): add HSTS subdir for new API for hsts tests,
this was code we previously used prior to 259132@main.
* Tools/TestWebKitAPI/glib/TestExpectations.json: Remove WPE failure
for hsts test.

Canonical link: https://commits.webkit.org/266326@main
  • Loading branch information
abstractmachines authored and TingPing committed Jul 26, 2023
1 parent dff1c2a commit c646f23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,13 @@ static void prepopulateHstsData()
// an IP address instead of a domain. In order to be able to test the data manager API with HSTS website data, we
// prepopulate the HSTS storage using the libsoup API directly.

#if !ENABLE(2022_GLIB_API)
GUniquePtr<char> hstsDatabase(g_build_filename(Test::dataDirectory(), "hsts-storage.sqlite", nullptr));
#else
GUniquePtr<char> hstsCacheDirectory(g_build_filename(Test::dataDirectory(), "HSTS", nullptr));
GUniquePtr<char> hstsDatabase(g_build_filename(hstsCacheDirectory.get(), "hsts-storage.sqlite", nullptr));
g_mkdir_with_parents(hstsCacheDirectory.get(), 0700);
#endif
GRefPtr<SoupHSTSEnforcer> enforcer = adoptGRef(soup_hsts_enforcer_db_new(hstsDatabase.get()));
GUniquePtr<SoupHSTSPolicy> policy(soup_hsts_policy_new("webkitgtk.org", 3600, true));
soup_hsts_enforcer_set_policy(enforcer.get(), policy.get());
Expand Down
3 changes: 0 additions & 3 deletions Tools/TestWebKitAPI/glib/TestExpectations.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@
"/webkit/WebKitWebsiteData/ephemeral": {
"expected": {"wpe": {"status": ["FAIL"], "bug": "webkit.org/b/256557"}}
},
"/webkit/WebKitWebsiteData/hsts": {
"expected": {"wpe": {"status": ["FAIL"], "bug": "webkit.org/b/256557"}}
},
"/webkit/WebKitWebsiteData/handle-corrupted-local-storage": {
"expected": {"wpe": {"status": ["FAIL"], "bug": "webkit.org/b/256557"}}
}
Expand Down

0 comments on commit c646f23

Please sign in to comment.