defmodule TarakanWeb.OAuthRateLimitTest do
  use TarakanWeb.ConnCase

  test "OAuth routes are rate limited per client IP" do
    for _ <- 1..20 do
      conn = get(build_conn(), ~p"/auth/github")
      assert conn.status == 302
    end

    conn = get(build_conn(), ~p"/auth/github")
    assert conn.status == 429
    assert text_response(conn, 429) =~ "too many requests"

    conn = get(build_conn(), ~p"/auth/gitlab")
    assert conn.status == 429
  end
end
