warmpath 0.3.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: warmpath
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Local LinkedIn visible-connections scraper.
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: browser-cookie3>=0.20.1
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "warmpath"
3
- version = "0.3.0"
3
+ version = "0.3.1"
4
4
  description = "Local LinkedIn visible-connections scraper."
5
5
  requires-python = ">=3.10"
6
6
  dependencies = [
@@ -50,6 +50,43 @@ def test_import_reads_only_the_selected_browser(browser, browser_cookies, monkey
50
50
  assert auth.load_auth().browser == browser
51
51
 
52
52
 
53
+ @pytest.mark.parametrize("secure", [0, 1])
54
+ def test_browser_cookie_integer_secure_flag_round_trips(secure, reader, browser_cookies, auth_path):
55
+ # browser-cookie3 passes Chrome's SQLite integer flags through to Cookie.
56
+ for cookie in list(browser_cookies):
57
+ browser_cookies.set_cookie(auth.browser_cookie3.create_cookie(
58
+ cookie.domain, cookie.path, secure, cookie.expires,
59
+ cookie.name, cookie.value, True,
60
+ ))
61
+
62
+ cli.main(["auth", "import", "--browser", "chrome"])
63
+ cli.main(["auth", "status"])
64
+
65
+ payload = json.loads(auth_path.read_text())
66
+ assert all(record["secure"] is bool(secure) for record in payload["cookies"])
67
+ assert auth.load_cookies().get_dict() == browser_cookies.get_dict()
68
+ assert all(cookie.secure is bool(secure) for cookie in auth.load_cookies())
69
+
70
+
71
+ @pytest.mark.parametrize("secure", [0, 1])
72
+ def test_existing_integer_secure_flags_load_without_reimport(secure, reader, auth_path):
73
+ auth.import_browser("chrome")
74
+ payload = json.loads(auth_path.read_text())
75
+ for record in payload["cookies"]:
76
+ record["secure"] = secure
77
+ auth_path.write_text(json.dumps(payload))
78
+ before = auth_path.read_bytes()
79
+ reader.reset_mock()
80
+
81
+ cli.main(["auth", "status"])
82
+ cookies = auth.load_cookies()
83
+
84
+ assert not auth.load_auth().missing_cookies()
85
+ assert all(cookie.secure is bool(secure) for cookie in cookies)
86
+ assert auth_path.read_bytes() == before
87
+ reader.assert_not_called()
88
+
89
+
53
90
  def test_import_filters_unrelated_expired_and_out_of_scope_cookies(reader, browser_cookies, auth_path):
54
91
  for name, domain, path, expires, value in [
55
92
  ("tracking", ".linkedin.com", "/", None, "unrelated-tracking-token"),
@@ -215,6 +252,7 @@ def test_corrupt_store_has_reimport_guidance(content, auth_path, capsys):
215
252
 
216
253
  @pytest.mark.parametrize("field,value", [
217
254
  ("domain", "example.org"), ("path", "/jobs"), ("secure", "true"),
255
+ ("secure", 2), ("secure", -1), ("secure", 0.0), ("secure", 1.0), ("secure", None),
218
256
  ("expires", "tomorrow"), ("expires", 10**20),
219
257
  ("domain_specified", False), ("value", "token\r\nInjected: header"),
220
258
  ])
@@ -616,7 +616,7 @@ wheels = [
616
616
 
617
617
  [[package]]
618
618
  name = "warmpath"
619
- version = "0.3.0"
619
+ version = "0.3.1"
620
620
  source = { editable = "." }
621
621
  dependencies = [
622
622
  { name = "browser-cookie3" },
@@ -93,7 +93,7 @@ def save_auth(session: AuthSession) -> None:
93
93
  "domain": cookie.domain,
94
94
  "domain_specified": cookie.domain_specified,
95
95
  "path": cookie.path,
96
- "secure": cookie.secure,
96
+ "secure": bool(cookie.secure),
97
97
  "expires": cookie.expires,
98
98
  }
99
99
  for cookie in session.cookies
@@ -173,7 +173,9 @@ def load_auth() -> AuthSession:
173
173
  not isinstance(record.get(key), str)
174
174
  for key in ("name", "value", "domain", "path")
175
175
  )
176
- or type(record.get("secure")) is not bool
176
+ # Older imports saved browser-cookie3's integer 0/1 Secure flag.
177
+ or type(record.get("secure")) not in (bool, int)
178
+ or record["secure"] not in (0, 1)
177
179
  or type(record.get("domain_specified")) is not bool
178
180
  or (
179
181
  record.get("expires") is not None
@@ -186,7 +188,7 @@ def load_auth() -> AuthSession:
186
188
  value=record["value"],
187
189
  domain=record["domain"],
188
190
  path=record["path"],
189
- secure=record["secure"],
191
+ secure=bool(record["secure"]),
190
192
  expires=record.get("expires"),
191
193
  )
192
194
  cookie.domain_specified = record["domain_specified"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes