e2e: Connect to Azure Database for PostgreSQL with Entra ID managed credentials on the workbench-azure lane

Open
#17,648 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
azure, postgresql, typescript
Domain
databases, testing

Research direction

Read the existing managed credentials test at test/e2e/tests/workbench/managed-credentials/managed-credentials-azure.test.ts and the PostgreSQL connection test at test/e2e/tests/data-connections/postgres.test.ts. First establish the listed Azure server, tenant consent, lane sign-in scope, database role, secrets, and session packages. Add the tagged end-to-end coverage for the mechanism, connection identity, generated snippets, and rejection of non-Azure hosts; done when those checks pass on the workbench-azure lane.

Written by the indexing model from the issue text.

Description

area: connections area: workbench testing

Summary

#17572 adds an Entra ID (Workbench Managed Credentials) connection mechanism to the PostgreSQL driver. On Posit Workbench, the password is a delegated Entra ID access token that Workbench issues for the signed-in user. It goes only to an Azure Database for PostgreSQL host, and only with certificate verification.

Vitest covers the token client, error classification and the host check. An extension-host test covers the SSL options (sslVerify gives rejectUnauthorized: true). No test runs the mechanism end to end. These parts are untested:

  • the connect path: a token from Workbench, the user name from the token, the connection to Azure
  • the generated code
  • certificate verification against a real Azure server

The workbench-azure lane already signs in to Workbench with Entra ID as the Positron service account (#17574). That makes an e2e test possible once the infrastructure below exists.

Test cases

Tag: @:workbench-azure (maybe also @:connections). Put the test next to test/e2e/tests/workbench/managed-credentials/managed-credentials-azure.test.ts, and reuse the dataConnections page object that test/e2e/tests/data-connections/postgres.test.ts uses.

  1. The mechanism appears. In New Connection > PostgreSQL, the Entra ID (Workbench Managed Credentials) mechanism is listed.

  2. Connect with an empty User. Enter the Azure host and database and leave User empty. Expected results:

    • the connection succeeds
    • the schema tree loads and a known table opens
    • the connection runs as [email protected]
  3. Generated code. Open the code preview and check that the Python (psycopg2 and SQLAlchemy) and R snippets have:

    • no literal token
    • sslmode set to verify-full
    • a token fetched with posit-sdk (get_delegated_azure_token) or rstudioapi (getDelegatedAzureToken)

    Optional: run one snippet in the console and check that a query returns rows.

  4. A non-Azure host is refused. With a host such as db.example.com, Connect fails and shows the "only sent to Azure Database for PostgreSQL servers" message. No token is requested.

Infrastructure needed

  • An Azure Database for PostgreSQL flexible server with Microsoft Entra ID authentication on. The lane's runners must be able to reach it (firewall or network rule).
  • Admin consent in the tenant for the Workbench Entra ID app to request delegated tokens for the Azure Database for PostgreSQL resource (https://ossrdbms-aad.database.windows.net).
  • The lane's Workbench requests the offline_access scope at sign-in. Delegated tokens need it.
  • A database role for [email protected], for example SELECT * FROM pgaadauth_create_principal('[email protected]', false, false);, with read access to a small seeded database.
  • The server host name and database name in the lane's secrets (1Password), for example E2E_AZURE_POSTGRES_HOST.
  • If generated code is run in test 3: posit-sdk 0.15.1 or later and rstudioapi 0.18.0 or later in the session image.

Dependencies

  • #17588 (merged): Workbench lanes run the PR's Positron build, not the build that Workbench ships. Without it, this test would not exercise the change.
  • #17574 (merged): sign-in to the azure lane as the Positron service account.

Raised in review of #17572.

Dominant language
TypeScript
Stars
4.4k
Forks
207
Avg merge
1d 16h
Merged PRs (30d)
308

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from posit-dev/positron

All issues in posit-dev/positron

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.