diff --git a/src/finch/_client.py b/src/finch/_client.py index 3794263e..be3e859b 100644 --- a/src/finch/_client.py +++ b/src/finch/_client.py @@ -68,8 +68,6 @@ class Finch(SyncAPIClient): access_token: str | None client_id: str | None client_secret: str | None - sandbox_client_id: str | None - sandbox_client_secret: str | None webhook_secret: str | None def __init__( @@ -78,8 +76,6 @@ def __init__( access_token: str | None = None, client_id: str | None = None, client_secret: str | None = None, - sandbox_client_id: str | None = None, - sandbox_client_secret: str | None = None, webhook_secret: str | None = None, base_url: str | httpx.URL | None = None, timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN, @@ -111,8 +107,6 @@ def __init__( This automatically infers the following arguments from their corresponding environment variables if they are not provided: - `client_id` from `FINCH_CLIENT_ID` - `client_secret` from `FINCH_CLIENT_SECRET` - - `sandbox_client_id` from `FINCH_SANDBOX_CLIENT_ID` - - `sandbox_client_secret` from `FINCH_SANDBOX_CLIENT_SECRET` - `webhook_secret` from `FINCH_WEBHOOK_SECRET` """ self.access_token = access_token @@ -125,14 +119,6 @@ def __init__( client_secret = os.environ.get("FINCH_CLIENT_SECRET") self.client_secret = client_secret - if sandbox_client_id is None: - sandbox_client_id = os.environ.get("FINCH_SANDBOX_CLIENT_ID") - self.sandbox_client_id = sandbox_client_id - - if sandbox_client_secret is None: - sandbox_client_secret = os.environ.get("FINCH_SANDBOX_CLIENT_SECRET") - self.sandbox_client_secret = sandbox_client_secret - if webhook_secret is None: webhook_secret = os.environ.get("FINCH_WEBHOOK_SECRET") self.webhook_secret = webhook_secret @@ -191,11 +177,11 @@ def _bearer_auth(self) -> dict[str, str]: @property def _basic_auth(self) -> dict[str, str]: - if self.sandbox_client_id is None: + if self.client_id is None: return {} - if self.sandbox_client_secret is None: + if self.client_secret is None: return {} - credentials = f"{self.sandbox_client_id}:{self.sandbox_client_secret}".encode("ascii") + credentials = f"{self.client_id}:{self.client_secret}".encode("ascii") header = f"Basic {base64.b64encode(credentials).decode('ascii')}" return {"Authorization": header} @@ -216,13 +202,13 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None: if isinstance(custom_headers.get("Authorization"), Omit): return - if self.sandbox_client_id and self.sandbox_client_secret and headers.get("Authorization"): + if self.client_id and self.client_secret and headers.get("Authorization"): return if isinstance(custom_headers.get("Authorization"), Omit): return raise TypeError( - '"Could not resolve authentication method. Expected either access_token, sandbox_client_id or sandbox_client_secret to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted"' + '"Could not resolve authentication method. Expected either access_token, client_id or client_secret to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted"' ) def copy( @@ -231,8 +217,6 @@ def copy( access_token: str | None = None, client_id: str | None = None, client_secret: str | None = None, - sandbox_client_id: str | None = None, - sandbox_client_secret: str | None = None, webhook_secret: str | None = None, base_url: str | httpx.URL | None = None, timeout: float | Timeout | None | NotGiven = NOT_GIVEN, @@ -288,8 +272,6 @@ def copy( access_token=access_token or self.access_token, client_id=client_id or self.client_id, client_secret=client_secret or self.client_secret, - sandbox_client_id=sandbox_client_id or self.sandbox_client_id, - sandbox_client_secret=sandbox_client_secret or self.sandbox_client_secret, webhook_secret=webhook_secret or self.webhook_secret, base_url=base_url or self.base_url, timeout=self.timeout if isinstance(timeout, NotGiven) else timeout, @@ -356,8 +338,6 @@ class AsyncFinch(AsyncAPIClient): access_token: str | None client_id: str | None client_secret: str | None - sandbox_client_id: str | None - sandbox_client_secret: str | None webhook_secret: str | None def __init__( @@ -366,8 +346,6 @@ def __init__( access_token: str | None = None, client_id: str | None = None, client_secret: str | None = None, - sandbox_client_id: str | None = None, - sandbox_client_secret: str | None = None, webhook_secret: str | None = None, base_url: str | httpx.URL | None = None, timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN, @@ -399,8 +377,6 @@ def __init__( This automatically infers the following arguments from their corresponding environment variables if they are not provided: - `client_id` from `FINCH_CLIENT_ID` - `client_secret` from `FINCH_CLIENT_SECRET` - - `sandbox_client_id` from `FINCH_SANDBOX_CLIENT_ID` - - `sandbox_client_secret` from `FINCH_SANDBOX_CLIENT_SECRET` - `webhook_secret` from `FINCH_WEBHOOK_SECRET` """ self.access_token = access_token @@ -413,14 +389,6 @@ def __init__( client_secret = os.environ.get("FINCH_CLIENT_SECRET") self.client_secret = client_secret - if sandbox_client_id is None: - sandbox_client_id = os.environ.get("FINCH_SANDBOX_CLIENT_ID") - self.sandbox_client_id = sandbox_client_id - - if sandbox_client_secret is None: - sandbox_client_secret = os.environ.get("FINCH_SANDBOX_CLIENT_SECRET") - self.sandbox_client_secret = sandbox_client_secret - if webhook_secret is None: webhook_secret = os.environ.get("FINCH_WEBHOOK_SECRET") self.webhook_secret = webhook_secret @@ -479,11 +447,11 @@ def _bearer_auth(self) -> dict[str, str]: @property def _basic_auth(self) -> dict[str, str]: - if self.sandbox_client_id is None: + if self.client_id is None: return {} - if self.sandbox_client_secret is None: + if self.client_secret is None: return {} - credentials = f"{self.sandbox_client_id}:{self.sandbox_client_secret}".encode("ascii") + credentials = f"{self.client_id}:{self.client_secret}".encode("ascii") header = f"Basic {base64.b64encode(credentials).decode('ascii')}" return {"Authorization": header} @@ -504,13 +472,13 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None: if isinstance(custom_headers.get("Authorization"), Omit): return - if self.sandbox_client_id and self.sandbox_client_secret and headers.get("Authorization"): + if self.client_id and self.client_secret and headers.get("Authorization"): return if isinstance(custom_headers.get("Authorization"), Omit): return raise TypeError( - '"Could not resolve authentication method. Expected either access_token, sandbox_client_id or sandbox_client_secret to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted"' + '"Could not resolve authentication method. Expected either access_token, client_id or client_secret to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted"' ) def copy( @@ -519,8 +487,6 @@ def copy( access_token: str | None = None, client_id: str | None = None, client_secret: str | None = None, - sandbox_client_id: str | None = None, - sandbox_client_secret: str | None = None, webhook_secret: str | None = None, base_url: str | httpx.URL | None = None, timeout: float | Timeout | None | NotGiven = NOT_GIVEN, @@ -576,8 +542,6 @@ def copy( access_token=access_token or self.access_token, client_id=client_id or self.client_id, client_secret=client_secret or self.client_secret, - sandbox_client_id=sandbox_client_id or self.sandbox_client_id, - sandbox_client_secret=sandbox_client_secret or self.sandbox_client_secret, webhook_secret=webhook_secret or self.webhook_secret, base_url=base_url or self.base_url, timeout=self.timeout if isinstance(timeout, NotGiven) else timeout, diff --git a/tests/api_resources/connect/test_sessions.py b/tests/api_resources/connect/test_sessions.py index ed7152d3..6ea14912 100644 --- a/tests/api_resources/connect/test_sessions.py +++ b/tests/api_resources/connect/test_sessions.py @@ -20,7 +20,6 @@ class TestSessions: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize def test_method_new(self, client: Finch) -> None: session = client.connect.sessions.new( @@ -30,7 +29,6 @@ def test_method_new(self, client: Finch) -> None: ) assert_matches_type(SessionNewResponse, session, path=["response"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize def test_method_new_with_all_params(self, client: Finch) -> None: session = client.connect.sessions.new( @@ -49,7 +47,6 @@ def test_method_new_with_all_params(self, client: Finch) -> None: ) assert_matches_type(SessionNewResponse, session, path=["response"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize def test_raw_response_new(self, client: Finch) -> None: response = client.connect.sessions.with_raw_response.new( @@ -63,7 +60,6 @@ def test_raw_response_new(self, client: Finch) -> None: session = response.parse() assert_matches_type(SessionNewResponse, session, path=["response"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize def test_streaming_response_new(self, client: Finch) -> None: with client.connect.sessions.with_streaming_response.new( @@ -79,7 +75,6 @@ def test_streaming_response_new(self, client: Finch) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize def test_method_reauthenticate(self, client: Finch) -> None: session = client.connect.sessions.reauthenticate( @@ -87,7 +82,6 @@ def test_method_reauthenticate(self, client: Finch) -> None: ) assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize def test_method_reauthenticate_with_all_params(self, client: Finch) -> None: session = client.connect.sessions.reauthenticate( @@ -98,7 +92,6 @@ def test_method_reauthenticate_with_all_params(self, client: Finch) -> None: ) assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize def test_raw_response_reauthenticate(self, client: Finch) -> None: response = client.connect.sessions.with_raw_response.reauthenticate( @@ -110,7 +103,6 @@ def test_raw_response_reauthenticate(self, client: Finch) -> None: session = response.parse() assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize def test_streaming_response_reauthenticate(self, client: Finch) -> None: with client.connect.sessions.with_streaming_response.reauthenticate( @@ -128,7 +120,6 @@ def test_streaming_response_reauthenticate(self, client: Finch) -> None: class TestAsyncSessions: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize async def test_method_new(self, async_client: AsyncFinch) -> None: session = await async_client.connect.sessions.new( @@ -138,7 +129,6 @@ async def test_method_new(self, async_client: AsyncFinch) -> None: ) assert_matches_type(SessionNewResponse, session, path=["response"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize async def test_method_new_with_all_params(self, async_client: AsyncFinch) -> None: session = await async_client.connect.sessions.new( @@ -157,7 +147,6 @@ async def test_method_new_with_all_params(self, async_client: AsyncFinch) -> Non ) assert_matches_type(SessionNewResponse, session, path=["response"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize async def test_raw_response_new(self, async_client: AsyncFinch) -> None: response = await async_client.connect.sessions.with_raw_response.new( @@ -171,7 +160,6 @@ async def test_raw_response_new(self, async_client: AsyncFinch) -> None: session = response.parse() assert_matches_type(SessionNewResponse, session, path=["response"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize async def test_streaming_response_new(self, async_client: AsyncFinch) -> None: async with async_client.connect.sessions.with_streaming_response.new( @@ -187,7 +175,6 @@ async def test_streaming_response_new(self, async_client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize async def test_method_reauthenticate(self, async_client: AsyncFinch) -> None: session = await async_client.connect.sessions.reauthenticate( @@ -195,7 +182,6 @@ async def test_method_reauthenticate(self, async_client: AsyncFinch) -> None: ) assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize async def test_method_reauthenticate_with_all_params(self, async_client: AsyncFinch) -> None: session = await async_client.connect.sessions.reauthenticate( @@ -206,7 +192,6 @@ async def test_method_reauthenticate_with_all_params(self, async_client: AsyncFi ) assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize async def test_raw_response_reauthenticate(self, async_client: AsyncFinch) -> None: response = await async_client.connect.sessions.with_raw_response.reauthenticate( @@ -218,7 +203,6 @@ async def test_raw_response_reauthenticate(self, async_client: AsyncFinch) -> No session = response.parse() assert_matches_type(SessionReauthenticateResponse, session, path=["response"]) - @pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server") @parametrize async def test_streaming_response_reauthenticate(self, async_client: AsyncFinch) -> None: async with async_client.connect.sessions.with_streaming_response.reauthenticate( diff --git a/tests/api_resources/sandbox/connections/test_accounts.py b/tests/api_resources/sandbox/connections/test_accounts.py index 1921e899..ad8027b1 100644 --- a/tests/api_resources/sandbox/connections/test_accounts.py +++ b/tests/api_resources/sandbox/connections/test_accounts.py @@ -20,7 +20,6 @@ class TestAccounts: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize def test_method_create(self, client: Finch) -> None: account = client.sandbox.connections.accounts.create( @@ -29,7 +28,6 @@ def test_method_create(self, client: Finch) -> None: ) assert_matches_type(AccountCreateResponse, account, path=["response"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize def test_method_create_with_all_params(self, client: Finch) -> None: account = client.sandbox.connections.accounts.create( @@ -40,7 +38,6 @@ def test_method_create_with_all_params(self, client: Finch) -> None: ) assert_matches_type(AccountCreateResponse, account, path=["response"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize def test_raw_response_create(self, client: Finch) -> None: response = client.sandbox.connections.accounts.with_raw_response.create( @@ -53,7 +50,6 @@ def test_raw_response_create(self, client: Finch) -> None: account = response.parse() assert_matches_type(AccountCreateResponse, account, path=["response"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize def test_streaming_response_create(self, client: Finch) -> None: with client.sandbox.connections.accounts.with_streaming_response.create( @@ -104,7 +100,6 @@ def test_streaming_response_update(self, client: Finch) -> None: class TestAsyncAccounts: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize async def test_method_create(self, async_client: AsyncFinch) -> None: account = await async_client.sandbox.connections.accounts.create( @@ -113,7 +108,6 @@ async def test_method_create(self, async_client: AsyncFinch) -> None: ) assert_matches_type(AccountCreateResponse, account, path=["response"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize async def test_method_create_with_all_params(self, async_client: AsyncFinch) -> None: account = await async_client.sandbox.connections.accounts.create( @@ -124,7 +118,6 @@ async def test_method_create_with_all_params(self, async_client: AsyncFinch) -> ) assert_matches_type(AccountCreateResponse, account, path=["response"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize async def test_raw_response_create(self, async_client: AsyncFinch) -> None: response = await async_client.sandbox.connections.accounts.with_raw_response.create( @@ -137,7 +130,6 @@ async def test_raw_response_create(self, async_client: AsyncFinch) -> None: account = response.parse() assert_matches_type(AccountCreateResponse, account, path=["response"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize async def test_streaming_response_create(self, async_client: AsyncFinch) -> None: async with async_client.sandbox.connections.accounts.with_streaming_response.create( diff --git a/tests/api_resources/sandbox/test_connections.py b/tests/api_resources/sandbox/test_connections.py index 574747fb..97209c33 100644 --- a/tests/api_resources/sandbox/test_connections.py +++ b/tests/api_resources/sandbox/test_connections.py @@ -17,7 +17,6 @@ class TestConnections: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize def test_method_create(self, client: Finch) -> None: connection = client.sandbox.connections.create( @@ -25,7 +24,6 @@ def test_method_create(self, client: Finch) -> None: ) assert_matches_type(ConnectionCreateResponse, connection, path=["response"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize def test_method_create_with_all_params(self, client: Finch) -> None: connection = client.sandbox.connections.create( @@ -36,7 +34,6 @@ def test_method_create_with_all_params(self, client: Finch) -> None: ) assert_matches_type(ConnectionCreateResponse, connection, path=["response"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize def test_raw_response_create(self, client: Finch) -> None: response = client.sandbox.connections.with_raw_response.create( @@ -48,7 +45,6 @@ def test_raw_response_create(self, client: Finch) -> None: connection = response.parse() assert_matches_type(ConnectionCreateResponse, connection, path=["response"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize def test_streaming_response_create(self, client: Finch) -> None: with client.sandbox.connections.with_streaming_response.create( @@ -66,7 +62,6 @@ def test_streaming_response_create(self, client: Finch) -> None: class TestAsyncConnections: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize async def test_method_create(self, async_client: AsyncFinch) -> None: connection = await async_client.sandbox.connections.create( @@ -74,7 +69,6 @@ async def test_method_create(self, async_client: AsyncFinch) -> None: ) assert_matches_type(ConnectionCreateResponse, connection, path=["response"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize async def test_method_create_with_all_params(self, async_client: AsyncFinch) -> None: connection = await async_client.sandbox.connections.create( @@ -85,7 +79,6 @@ async def test_method_create_with_all_params(self, async_client: AsyncFinch) -> ) assert_matches_type(ConnectionCreateResponse, connection, path=["response"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize async def test_raw_response_create(self, async_client: AsyncFinch) -> None: response = await async_client.sandbox.connections.with_raw_response.create( @@ -97,7 +90,6 @@ async def test_raw_response_create(self, async_client: AsyncFinch) -> None: connection = response.parse() assert_matches_type(ConnectionCreateResponse, connection, path=["response"]) - @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize async def test_streaming_response_create(self, async_client: AsyncFinch) -> None: async with async_client.sandbox.connections.with_streaming_response.create( diff --git a/tests/test_client.py b/tests/test_client.py index f0c81df6..276a61dc 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -391,7 +391,7 @@ def test_validate_headers(self) -> None: with pytest.raises( TypeError, - match="Could not resolve authentication method. Expected either access_token, sandbox_client_id or sandbox_client_secret to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted", + match="Could not resolve authentication method. Expected either access_token, client_id or client_secret to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted", ): client2._build_request(FinalRequestOptions(method="get", url="/foo")) @@ -1353,7 +1353,7 @@ def test_validate_headers(self) -> None: with pytest.raises( TypeError, - match="Could not resolve authentication method. Expected either access_token, sandbox_client_id or sandbox_client_secret to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted", + match="Could not resolve authentication method. Expected either access_token, client_id or client_secret to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted", ): client2._build_request(FinalRequestOptions(method="get", url="/foo"))