From eac483ff1354e1e4b7c1334527cd6b832cec1de3 Mon Sep 17 00:00:00 2001 From: Wolf Date: Tue, 29 Sep 2026 20:08:37 +0200 Subject: [PATCH] Read Rippling's boards, merging a role's places, and its pay and description from the role's record Co-Authored-By: Claude Sonnet 5.5 --- plugins/atshosts/rippling.py | 127 ++++++++++++++ tests/fixtures/ats/rippling-prisma.json | 1 + tests/fixtures/ats/rippling-role-2.json | 53 ++++++ tests/fixtures/ats/rippling-role.json | 61 +++++++ tests/fixtures/ats/rippling.json | 106 ++++++++++++ tests/test_ats_rippling.py | 212 ++++++++++++++++++++++++ 6 files changed, 560 insertions(+) create mode 100644 plugins/atshosts/rippling.py create mode 100644 tests/fixtures/ats/rippling-prisma.json create mode 100644 tests/fixtures/ats/rippling-role-2.json create mode 100644 tests/fixtures/ats/rippling-role.json create mode 100644 tests/fixtures/ats/rippling.json create mode 100644 tests/test_ats_rippling.py diff --git a/plugins/atshosts/rippling.py b/plugins/atshosts/rippling.py new file mode 100644 index 0000000..a8e81f0 --- /dev/null +++ b/plugins/atshosts/rippling.py @@ -0,0 +1,127 @@ +"""Rippling: `rippling:` for ats.rippling.com/, the whole +board in one JSON array, the description on each role's own record. + +Written from Prisma's board (`prisma-careers`, two roles) and Rippling's own +(`rippling`, 326 roles) on 2026-09-29. The careers site's script reads the +public board API, `api.rippling.com/platform/api/ats/v1/board//jobs`, +which needs no key. The slug is case-sensitive (`Prisma-Careers` is "Job +Board not found"). +""" + +from __future__ import annotations + +import html +import json +import re +from collections.abc import Callable +from typing import Any + +from desk.sources import strip_html + +from ._shared import Get, Row, parse_dt, yearly_amount + +NAME = "rippling" +LABEL = "Rippling" +KEEP_CASE = True +PATTERNS = ( + r"ats\.rippling\.com/([A-Za-z0-9][A-Za-z0-9_-]*)", + r"api\.rippling\.com/platform/api/ats/v1/board/([A-Za-z0-9][A-Za-z0-9_-]*)", +) + +_API = "api.rippling.com" +_SITE = "ats.rippling.com" + +#: A slug is one path segment that starts with a letter or a digit, matched +#: whole; it is also what discovery's patterns take. +_SLUG = re.compile(r"[A-Za-z0-9][A-Za-z0-9_-]*") + +#: A role's id in the board's own links. +_UUID = re.compile(r"[0-9A-Za-z-]{8,64}") + + +def slug_ok(slug: str) -> bool: + return bool(_SLUG.fullmatch(slug)) + + +def allowed(slug: str) -> Callable[[str], bool]: + return lambda host: host.lower() in (_API, _SITE) + + +def careers_url(slug: str) -> str: + return f"https://{_SITE}/{slug}/jobs" + + +def robots_page(slug: str) -> str: + """The page a person opens. The API host has no robots.txt (a 404, which + allows), so the site's is the one that says something.""" + return careers_url(slug) + + +def _board(slug: str) -> str: + return f"https://{_API}/platform/api/ats/v1/board/{slug}" + + +def feed_url(slug: str) -> str: + return f"{_board(slug)}/jobs" + + +def parse(body: bytes, slug: str) -> list[Row]: + """The board's array -> one row per role. The array has one entry per + role and place, so a role in three cities is three entries with one + `uuid` (Rippling's own board: 638 entries, 326 roles); the rows merge + them, the places joined with "; ". The entry has no description, date + or pay: `detail` reads them. `remote` is True only when every place is a + "Remote (...)" one, since a label says nothing else about the work.""" + data = json.loads(body) + if not isinstance(data, list): + raise ValueError("not a Rippling board: the answer is not a list") + roles: dict[str, Row] = {} + places: dict[str, list[str]] = {} + for entry in data: + job_id = str(entry.get("uuid") or "").strip() + title = (entry.get("name") or "").strip() + if not title or not _UUID.fullmatch(job_id): + continue + place = str(((entry.get("workLocation") or {}).get("label")) or "").strip() + places.setdefault(job_id, []) + if place and place not in places[job_id]: + places[job_id].append(place) + roles.setdefault(job_id, { + "source_id": job_id, + "title": title, + "url": f"https://{_SITE}/{slug}/jobs/{job_id}", + "posted": None, + "department": str(((entry.get("department") or {}).get("label")) or "").strip(), + "description": "", + "salary_text": "", # the board's list states no pay + }) + for job_id, row in roles.items(): + row["location"] = "; ".join(places[job_id]) + row["remote"] = True if places[job_id] and all( + p.lower().startswith("remote") for p in places[job_id]) else None + return list(roles.values()) + + +def detail(get: Get, slug: str, row: Row) -> dict[str, Any]: + """`/jobs/`: the description as HTML (`description.role`, or + the company's text when a role has none), every place in `workLocations`, + `createdOn` for `posted`, and `payRangeDetails`, a range per pay zone. + The columns are only filled for exactly one yearly range, as Greenhouse's + are: with several zones there is no telling which one the role has.""" + data = json.loads(get(f"{_board(slug)}/jobs/{row['source_id']}")) + text = data.get("description") or {} + found: dict[str, Any] = { + "description": html.unescape(strip_html(text.get("role") or text.get("company") or "")), + "posted": parse_dt(data.get("createdOn")), + } + if places := [p for p in (str(p).strip() for p in data.get("workLocations") or []) if p]: + found["location"] = "; ".join(dict.fromkeys(places)) + ranges = data.get("payRangeDetails") or [] + if len(ranges) == 1: + pay = ranges[0] + lo, hi, currency = yearly_amount(pay.get("rangeStart"), pay.get("rangeEnd"), + pay.get("currency"), pay.get("frequency"), + {"YEAR": 1, "MONTH": 12}) + if currency: + found |= {"salary_min": lo, "salary_max": hi, "currency": currency} + return found diff --git a/tests/fixtures/ats/rippling-prisma.json b/tests/fixtures/ats/rippling-prisma.json new file mode 100644 index 0000000..9341c99 --- /dev/null +++ b/tests/fixtures/ats/rippling-prisma.json @@ -0,0 +1 @@ +[{"uuid":"0fbcec57-3012-4271-96bf-12b145cf6dea","name":"General Applications: Engineering","department":{"id":"Engineering","label":"Engineering"},"url":"https://ats.rippling.com/prisma-careers/jobs/0fbcec57-3012-4271-96bf-12b145cf6dea","workLocation":{"label":"Remote (Germany)","id":"Remote (Germany)"}},{"uuid":"f055f01a-81c0-4d92-bbe1-6d6e7a8112df","name":"General Applications: Product","department":{"id":"Product","label":"Product"},"url":"https://ats.rippling.com/prisma-careers/jobs/f055f01a-81c0-4d92-bbe1-6d6e7a8112df","workLocation":{"label":"Remote (Germany)","id":"Remote (Germany)"}}] \ No newline at end of file diff --git a/tests/fixtures/ats/rippling-role-2.json b/tests/fixtures/ats/rippling-role-2.json new file mode 100644 index 0000000..2bf5f4c --- /dev/null +++ b/tests/fixtures/ats/rippling-role-2.json @@ -0,0 +1,53 @@ +{ + "uuid": "0fbcec57-3012-4271-96bf-12b145cf6dea", + "name": "General Applications: Engineering", + "description": { + "company": "

Not finding the perfect engineering role on our careers page?

We are constantly seeking talented individuals to join our team. If you are a Software Engineer and haven\u2019t found the perfect role on our careers page, don\u2019t worry \u2014 you\u2019ve come to the right place.


We strongly believe that each person has something unique to bring to the table. Whether you\u2019re a recent graduate or a seasoned professional, we\u2019re genuinely excited to hear from you. At Prisma, we work with modern technologies, including TypeScript", + "role": "

What is it like to work at Prisma?

You're likely to be a great fit for the team if you ...

  • ... have an ownership mindset. As part of a small team, you'll have an outsize impact on decisions and the way things are executed.
  • ... stay nimble. As a growing startup, the team and strategy evolves quickly. Be ready to re-calibrate often and stay flexible.

    " + }, + "workLocations": [ + "Remote (Germany)" + ], + "department": { + "name": "Engineering", + "base_department": "Engineering", + "department_tree": [ + "Engineering" + ] + }, + "employmentType": { + "label": "SALARIED_FT", + "id": "Full-Time Employee" + }, + "createdOn": "2024-11-14T01:57:03.744000-08:00", + "eeocQuestionnaireEnabled": false, + "eeocQuestionnaireEnabledForJobPost": false, + "url": "https://ats.rippling.com/prisma-careers/jobs/0fbcec57-3012-4271-96bf-12b145cf6dea", + "board": { + "boardType": "RIPPLING", + "slug": "prisma-careers", + "banner": { + "name": "", + "url": null, + "type": "" + }, + "title": "Join Prisma", + "subtitle": "At Prisma, we are building the data layer for modern apps. Join our distributed team, backed by top investors, with 380k+ users!", + "boardURL": "https://ats.rippling.com/prisma-careers/jobs", + "fontType": "ARIAL_SANS_SERIF", + "linkColor": null, + "buttonColor": "#5a67d8", + "buttonTextColor": null, + "noOpeningsMessage": null, + "groupJobsByLocation": true, + "showBoardLogoOnJobPost": false, + "showCompanyInfoUnderJobPost": false, + "companyName": "Prisma Data, Inc." + }, + "payRangeDetails": [], + "applicationConfirmationTemplate": "66b4c6bc65d129d95c33c48b", + "hasAIEvaluationsEnabled": false, + "companyName": "Prisma Data, Inc.", + "unlistedFromSearch": false, + "jsonLd": null +} diff --git a/tests/fixtures/ats/rippling-role.json b/tests/fixtures/ats/rippling-role.json new file mode 100644 index 0000000..4ead046 --- /dev/null +++ b/tests/fixtures/ats/rippling-role.json @@ -0,0 +1,61 @@ +{ + "uuid": "2f2ae4c8-ec56-4d1f-8f2a-0d295674e19c", + "name": "Director of Engineering - Infrastructure", + "description": { + "company": "

    About Rippling

    Rippling gives businesses one place to run HR, IT, and Finance. It brings together all of the workforce systems that are normally scattered across a company, like payroll, expenses, benefits, and computers. For the first time ever, you can manage and automate every part of the employee lifecycle in a single system.

    Take onboarding, for example. With Rippling, you can hire a new employee anywhere in the world and set up their payroll, corporate card, computer, benefits, and even third-party apps like Slack and Microsoft 365\u2014all within 90 seconds.", + "role": "

    About The Role


    Rippling Infrastructure operates as a scaled engineering organization responsible for the mission-critical systems that power every product and platform across the company. We support nearly 1,000 engineers globally and deliver the foundational infrastructure that enables Rippling's products to scale reliably and efficiently.

    " + }, + "workLocations": [ + "San Francisco, CA", + "Seattle, WA", + "New York, NY" + ], + "department": { + "name": "Platform", + "base_department": "Engineering", + "department_tree": [ + "Engineering", + "Platform" + ] + }, + "employmentType": { + "label": "SALARIED_FT", + "id": "Salaried, full-time" + }, + "createdOn": "2025-04-07T12:29:19.348000-07:00", + "eeocQuestionnaireEnabled": true, + "eeocQuestionnaireEnabledForJobPost": true, + "url": "https://ats.rippling.com/rippling/jobs/2f2ae4c8-ec56-4d1f-8f2a-0d295674e19c", + "board": { + "boardType": "CUSTOM", + "slug": "rippling", + "banner": null, + "title": "Current Openings", + "subtitle": null, + "boardURL": "http://www.rippling.com/careers/open-roles", + "fontType": null, + "linkColor": null, + "buttonColor": null, + "buttonTextColor": null, + "noOpeningsMessage": null, + "groupJobsByLocation": false, + "showBoardLogoOnJobPost": false, + "showCompanyInfoUnderJobPost": false, + "companyName": "Rippling" + }, + "payRangeDetails": [ + { + "location": "US Tier 1", + "currency": "USD", + "frequency": "YEAR", + "rangeStart": 216000.0, + "rangeEnd": 378000.0, + "isRemote": false + } + ], + "applicationConfirmationTemplate": "6348729c5a9a6e6df0bb6f64", + "hasAIEvaluationsEnabled": true, + "companyName": "Rippling", + "unlistedFromSearch": false, + "jsonLd": null +} diff --git a/tests/fixtures/ats/rippling.json b/tests/fixtures/ats/rippling.json new file mode 100644 index 0000000..893505d --- /dev/null +++ b/tests/fixtures/ats/rippling.json @@ -0,0 +1,106 @@ +[ + { + "uuid": "75ad50c6-778f-42ee-9c63-70d1cd687202", + "name": "Account Executive, Broker Channel (Austin & San Antonio)", + "department": { + "id": "Sales", + "label": "Sales" + }, + "url": "https://ats.rippling.com/rippling/jobs/75ad50c6-778f-42ee-9c63-70d1cd687202", + "workLocation": { + "label": "Austin, TX", + "id": "Austin, TX" + } + }, + { + "uuid": "94486f41-6474-446a-b67a-c164e11354ea", + "name": "Account Executive, Broker Channel (Pittsburgh or Cleveland)", + "department": { + "id": "Sales", + "label": "Sales" + }, + "url": "https://ats.rippling.com/rippling/jobs/94486f41-6474-446a-b67a-c164e11354ea", + "workLocation": { + "label": "Pittsburgh, PA", + "id": "Pittsburgh, PA" + } + }, + { + "uuid": "94486f41-6474-446a-b67a-c164e11354ea", + "name": "Account Executive, Broker Channel (Pittsburgh or Cleveland)", + "department": { + "id": "Sales", + "label": "Sales" + }, + "url": "https://ats.rippling.com/rippling/jobs/94486f41-6474-446a-b67a-c164e11354ea", + "workLocation": { + "label": "Cleveland, OH", + "id": "Cleveland, OH" + } + }, + { + "uuid": "2f2ae4c8-ec56-4d1f-8f2a-0d295674e19c", + "name": "Director of Engineering - Infrastructure", + "department": { + "id": "Engineering", + "label": "Engineering" + }, + "url": "https://ats.rippling.com/rippling/jobs/2f2ae4c8-ec56-4d1f-8f2a-0d295674e19c", + "workLocation": { + "label": "San Francisco, CA", + "id": "San Francisco, CA" + } + }, + { + "uuid": "2f2ae4c8-ec56-4d1f-8f2a-0d295674e19c", + "name": "Director of Engineering - Infrastructure", + "department": { + "id": "Engineering", + "label": "Engineering" + }, + "url": "https://ats.rippling.com/rippling/jobs/2f2ae4c8-ec56-4d1f-8f2a-0d295674e19c", + "workLocation": { + "label": "Seattle, WA", + "id": "Seattle, WA" + } + }, + { + "uuid": "2f2ae4c8-ec56-4d1f-8f2a-0d295674e19c", + "name": "Director of Engineering - Infrastructure", + "department": { + "id": "Engineering", + "label": "Engineering" + }, + "url": "https://ats.rippling.com/rippling/jobs/2f2ae4c8-ec56-4d1f-8f2a-0d295674e19c", + "workLocation": { + "label": "New York, NY", + "id": "New York, NY" + } + }, + { + "uuid": "46b4af52-824b-4803-be84-e8ed57bd33a1", + "name": "Account Executive, Private Equity", + "department": { + "id": "Sales", + "label": "Sales" + }, + "url": "https://ats.rippling.com/rippling/jobs/46b4af52-824b-4803-be84-e8ed57bd33a1", + "workLocation": { + "label": "Remote (United States)", + "id": "Remote (United States)" + } + }, + { + "uuid": "19ae5b34-e7b7-4164-99d4-fc8f84bb37fe", + "name": "Accounting Manager, PEO Compliance", + "department": { + "id": "Finance", + "label": "Finance" + }, + "url": "https://ats.rippling.com/rippling/jobs/19ae5b34-e7b7-4164-99d4-fc8f84bb37fe", + "workLocation": { + "label": "Remote (United States)", + "id": "Remote (United States)" + } + } +] diff --git a/tests/test_ats_rippling.py b/tests/test_ats_rippling.py new file mode 100644 index 0000000..a60780f --- /dev/null +++ b/tests/test_ats_rippling.py @@ -0,0 +1,212 @@ +"""The Rippling host module against saved answers: a listing trimmed from +Rippling's own board, Prisma's whole listing, and two role records, +2026-09-29. No network.""" + +from __future__ import annotations + +import json +import sys +from pathlib import Path +from typing import Any + +import httpx +import pytest + +ROOT = Path(__file__).resolve().parents[1] +if str(ROOT) not in sys.path: + sys.path.insert(0, str(ROOT)) + +from app.jobs.discover import boards_in # noqa: E402 +from plugins import ats, atshosts # noqa: E402 +from plugins.atshosts import rippling # noqa: E402 + +FIXTURES = ROOT / "tests" / "fixtures" / "ats" +BOARD = (FIXTURES / "rippling.json").read_bytes() +PRISMA = (FIXTURES / "rippling-prisma.json").read_bytes() +FEED = "https://api.rippling.com/platform/api/ats/v1/board/rippling/jobs" +DIRECTOR = "2f2ae4c8-ec56-4d1f-8f2a-0d295674e19c" + + +def test_rows_merge_one_entry_per_place_into_one_role() -> None: + rows = rippling.parse(BOARD, "rippling") + assert [r["source_id"][:8] for r in rows] == [ + "75ad50c6", "94486f41", "2f2ae4c8", "46b4af52", "19ae5b34"] + by_id = {r["source_id"][:8]: r for r in rows} + assert by_id["94486f41"]["location"] == "Pittsburgh, PA; Cleveland, OH" + assert by_id["2f2ae4c8"]["location"] == "San Francisco, CA; Seattle, WA; New York, NY" + first = rows[0] + assert first["title"] == "Account Executive, Broker Channel (Austin & San Antonio)" + assert first["url"] == "https://ats.rippling.com/rippling/jobs/75ad50c6-778f-42ee-9c63-70d1cd687202" + assert first["department"] == "Sales" and first["location"] == "Austin, TX" + assert first["description"] == "" and first["salary_text"] == "" and first["posted"] is None + + +def test_remote_is_true_only_when_every_place_is_a_remote_one() -> None: + by_id = {r["source_id"][:8]: r for r in rippling.parse(BOARD, "rippling")} + assert by_id["46b4af52"]["remote"] is True and by_id["19ae5b34"]["remote"] is True + assert by_id["75ad50c6"]["remote"] is None # an office label says nothing either way + mixed = json.dumps([ + {"uuid": "abcdefgh-1", "name": "A", "workLocation": {"label": "Remote (Germany)"}}, + {"uuid": "abcdefgh-1", "name": "A", "workLocation": {"label": "Berlin"}}]).encode() + assert rippling.parse(mixed, "x")[0]["remote"] is None + + +def test_prisma_board_reads_two_roles() -> None: + rows = rippling.parse(PRISMA, "prisma-careers") + assert [(r["title"], r["department"], r["location"], r["remote"]) for r in rows] == [ + ("General Applications: Engineering", "Engineering", "Remote (Germany)", True), + ("General Applications: Product", "Product", "Remote (Germany)", True)] + + +def test_an_empty_board_is_no_roles_and_an_error_answer_is_not_a_board() -> None: + assert rippling.parse(b"[]", "acme") == [] + with pytest.raises(ValueError, match="not a Rippling board"): + rippling.parse(b'{"error_code":"RESOURCE_NOT_FOUND"}', "acme") + + +def test_an_entry_without_a_title_or_a_plain_id_is_skipped() -> None: + body = json.dumps([{"uuid": "abcdefgh-1", "name": " "}, {"name": "B"}, + {"uuid": "../../x", "name": "C"}, + {"uuid": "abcdefgh-2", "name": "D"}]).encode() + assert [r["source_id"] for r in rippling.parse(body, "acme")] == ["abcdefgh-2"] + + +# ---------------------------------------------------------------- detail + +def _get(answer: bytes, asked: list[str] | None = None) -> Any: + def get(url: str, *, method: str = "GET", payload: Any = None, + headers: dict[str, str] | None = None) -> bytes: + if asked is not None: + asked.append(url) + return answer + return get + + +def test_detail_reads_description_places_date_and_a_single_yearly_range() -> None: + row = {r["source_id"]: r for r in rippling.parse(BOARD, "rippling")}[DIRECTOR] + asked: list[str] = [] + found = rippling.detail(_get((FIXTURES / "rippling-role.json").read_bytes(), asked), + "rippling", row) + assert asked == [f"https://api.rippling.com/platform/api/ats/v1/board/rippling/jobs/{DIRECTOR}"] + assert set(found) <= set(ats.DETAIL_FIELDS) + assert found["description"].startswith("About The Role") + assert "<" not in found["description"] + assert found["location"] == "San Francisco, CA; Seattle, WA; New York, NY" + assert found["posted"] is not None and found["posted"].isoformat() == \ + "2025-04-07T12:29:19.348000-07:00" + assert (found["salary_min"], found["salary_max"], found["currency"]) == (216000, 378000, "USD") + + +def test_detail_without_pay_leaves_the_pay_columns_out() -> None: + found = rippling.detail(_get((FIXTURES / "rippling-role-2.json").read_bytes()), + "prisma-careers", {"source_id": "x"}) + assert found["description"].startswith("What is it like to work at Prisma?") + assert found["location"] == "Remote (Germany)" + assert not {"salary_min", "salary_max", "currency"} & set(found) + + +@pytest.mark.parametrize("ranges", [ + [], + [{"currency": "USD", "frequency": "HOUR", "rangeStart": 40, "rangeEnd": 60}], + [{"currency": "USD", "frequency": "YEAR", "rangeStart": 1, "rangeEnd": 2}, + {"currency": "USD", "frequency": "YEAR", "rangeStart": 3, "rangeEnd": 4}], # several zones + [{"currency": "", "frequency": "YEAR", "rangeStart": 1, "rangeEnd": 2}], +]) +def test_only_one_yearly_range_with_a_currency_fills_the_columns(ranges: list[Any]) -> None: + body = json.dumps({"description": {"role": "

    x

    "}, "payRangeDetails": ranges}).encode() + found = rippling.detail(_get(body), "acme", {"source_id": "x"}) + assert not {"salary_min", "salary_max", "currency"} & set(found) + assert found["description"] == "x" and found["posted"] is None + + +def test_a_monthly_range_is_made_yearly_and_the_company_text_stands_in_for_a_missing_role_text( +) -> None: + body = json.dumps({"description": {"company": "

    About us & more

    ", "role": ""}, + "payRangeDetails": [{"currency": "EUR", "frequency": "MONTH", + "rangeStart": 3000, "rangeEnd": None}]}).encode() + found = rippling.detail(_get(body), "acme", {"source_id": "x"}) + assert found["description"] == "About us & more" + assert (found["salary_min"], found["salary_max"], found["currency"]) == (36000, None, "EUR") + + +@pytest.fixture +def web(monkeypatch: pytest.MonkeyPatch) -> dict[str, Any]: + answers: dict[str, Any] = {} + asked: list[str] = [] + + def fake_get(client, url, host, slug, *, method="GET", payload=None, headers=None, + www_twin=False): + asked.append(url) + if not ats._allowed_host(host, slug)(httpx.URL(url).host): + raise ats._Refused(url) + answer = answers[url] + if isinstance(answer, BaseException): + raise answer + return answer + + monkeypatch.setattr(ats, "_get", fake_get) + return {"answers": answers, "asked": asked} + + +def test_the_board_is_one_request_and_complete(web: dict[str, Any]) -> None: + web["answers"][FEED] = BOARD + with httpx.Client() as client: + rows, complete = ats._fetch_rows(client, "rippling:rippling") + assert len(rows) == 5 and complete and web["asked"] == [FEED] + + +def test_robots_are_read_from_the_site_and_disallow_only_internal( + web: dict[str, Any]) -> None: + web["answers"]["https://ats.rippling.com/robots.txt"] = b"User-agent: *\nDisallow: /internal/\n" + with httpx.Client() as client: + ats._check_robots(client, "rippling:prisma-careers") + web["answers"]["https://ats.rippling.com/robots.txt"] = b"User-agent: *\nDisallow: /\n" + with pytest.raises(ats._Disallowed): + ats._check_robots(client, "rippling:prisma-careers") + + +# ------------------------------------------------------- slugs and hosts + +def test_the_module_is_registered_as_a_feed_host_with_detail() -> None: + assert atshosts.HOSTS["rippling"] is rippling and ats.HOSTS["rippling"] == "Rippling" + assert rippling.NAME == "rippling" and rippling.KEEP_CASE + assert hasattr(rippling, "detail") and not hasattr(rippling, "page") + + +def test_the_urls_and_the_robots_page() -> None: + assert rippling.feed_url("rippling") == FEED + assert rippling.careers_url("prisma-careers") == "https://ats.rippling.com/prisma-careers/jobs" + assert rippling.robots_page("prisma-careers") == rippling.careers_url("prisma-careers") + allow = rippling.allowed("rippling") + assert allow("api.rippling.com") and allow("ATS.RIPPLING.COM") + for host in ("rippling.com", "www.rippling.com", "api.rippling.com.evil.example", "localhost"): + assert not allow(host) + + +@pytest.mark.parametrize("slug", ["rippling", "prisma-careers", "Acme_2", "9x"]) +def test_a_slug_is_one_path_segment(slug: str) -> None: + assert ats.is_known_target(f"rippling:{slug}") + + +@pytest.mark.parametrize("slug", [ + "", "a@b", "a#b", "a?b", "..", ".", "a%2fb", "%2f", "a/b", "a:443", "a b", "acme\n", + " acme", "acme ", "127.0.0.1", "a.b", "_x", "-x", "a\\b", "évil", +]) +def test_a_hostile_slug_is_refused(slug: str) -> None: + assert not rippling.slug_ok(slug) + assert not ats.is_known_target(f"rippling:{slug}") + + +def test_no_slug_reaches_another_host() -> None: + for slug in ("rippling", "Prisma-Careers", "a-b_c"): + for url in (rippling.feed_url(slug), rippling.careers_url(slug), + rippling.robots_page(slug)): + assert httpx.URL(url).host in ("api.rippling.com", "ats.rippling.com") + + +def test_discovery_finds_the_board_slug() -> None: + page = ('Jobs' + 'Role' + '') + assert [(h, s) for h, s, _ in boards_in(page)] == [ + ("rippling", "prisma-careers"), ("rippling", "Acme"), ("rippling", "beta")]