Add OIDC authentication to integration tests#75
Open
lubomir wants to merge 1 commit into
Open
Conversation
dcf859a to
55b79f8
Compare
c59b61b to
0ab890a
Compare
c4d005d to
9c35910
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #75 +/- ##
==========================================
+ Coverage 81.95% 83.69% +1.74%
==========================================
Files 13 13
Lines 1302 1325 +23
==========================================
+ Hits 1067 1109 +42
+ Misses 235 216 -19
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Deploys Dex (OIDC provider) and a Python/ldaptor in-memory LDAP server alongside CTS in the EaaS pipeline and exercises the full mod_auth_openidc → load_openidc_user → get_user_info → query_ldap_groups → has_role auth stack end-to-end. Pipeline changes (.tekton/integration-test-eaas.yaml): - New deploy-openldap task: in-memory LDAP server (ldaptor) serving the cts-builders posixGroup, runs without root on any UID - New deploy-dex task: Dex with TLS (self-signed CA), password connector, static OAuth2 client cts-integration - Updated deploy-cts: AUTH_BACKEND=oidc_or_kerberos, httpd.conf with AuthType oauth20 / OIDCOAuthVerifyJwksUri / OIDCCABundlePath for bearer token validation; SetEnv OIDC_CLAIM_scope scoped to Bearer requests only - Updated run-tests: passes AUTH_BACKEND=oidc_or_kerberos; installs requests; writes Dex CA to /tmp and sets REQUESTS_CA_BUNDLE Test changes (tests/test_integration_api.py): - AuthHTTPClient: HTTPClient subclass that injects Authorization: Bearer - _get_oidc_token(): obtains a real access token from Dex via ROPC grant - _make_ssl_context(): builds an SSLContext from REQUESTS_CA_BUNDLE for use with urllib.request.urlopen - write_http_client fixture: returns AuthHTTPClient under OIDC or plain HTTPClient in noauth mode; pre-existing workflow tests use it - Four new tests (all four explicitly skip when not _is_oidc_backend()): - test_auth_unauthenticated_write_returns_401 - test_auth_builder_can_post_compose - test_auth_unauthorized_user_returns_403 - test_auth_get_endpoints_accessible_without_token Generated-By: OpenCode (google-vertex-anthropic/claude-sonnet-4-6@default)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add OIDC authentication to integration tests
Deploys Dex (OIDC provider) and an in-memory LDAP server (ldaptor) alongside CTS
in the EaaS pipeline and exercises the full
mod_auth_openidc→load_openidc_user→
get_user_info→query_ldap_groups→has_roleauth stack end-to-end.Pipeline changes (
.tekton/integration-test-eaas.yaml)deploy-openldaptask (runs in parallel withdeploy-dexafterprovision-environment): creates aConfigMapwith an in-memory LDAP serverscript (using ldaptor/Twisted) defining two users (
builder/readonly) andtwo groups (
cts-builders/readonly-users), then deploys the server on port1389.
deploy-dextask (parallel withdeploy-openldap): generates aself-signed CA and TLS certificate for Dex, creates a
ConfigMapwith a Dexconfig using the password connector and a static OAuth2 client
(
cts-integration), then deploys Dex on port 5556.deploy-cts:runAfternow includesdeploy-openldapanddeploy-dex. Thects-configConfigMap setsAUTH_BACKEND=oidc_or_kerberos,AUTH_OPENIDC_USERINFO_URI,AUTH_LDAP_SERVER(pointing toopenldap:1389),AUTH_LDAP_GROUPS,ADMINS, andALLOWED_BUILDERS. Thehttpd.confgainsmod_auth_openidcdirectives (OIDCProviderMetadataURL,OIDCOAuthVerifyJwksUri,OIDCClientID/Secret,OIDCRemoteUserClaim,OIDCCABundlePath) and a<RequireAny>block that allows unauthenticatedGET requests while requiring a valid Bearer token for writes.
run-tests: installsrequestsalongsidepytest, retrieves theDex CA certificate, and passes
AUTH_BACKEND=oidc_or_kerberosandDEX_URL=https://dex:5556to the test runner so the auth tests are not skipped.Test changes (
tests/test_integration_api.py)AuthHTTPClient:HTTPClientsubclass that injectsAuthorization: Beareron every request.
_get_oidc_token(): obtains a real access token from Dex via the ROPC grant;used by
auth_http_client_builderandauth_http_client_readonlyfixtures.write_http_clientfixture: returns anAuthHTTPClient(asbuilder) whenOIDC is active, or a plain
HTTPClientin noauth mode. Existing workflow teststhat perform writes are updated to use this fixture.
AUTH_BACKENDis notopenidcoroidc_or_kerberos):test_auth_unauthenticated_write_returns_401– bare POST → 401test_auth_builder_can_post_compose–builderBearer token → 200test_auth_unauthorized_user_returns_403–readonlyBearer token → 403test_auth_get_endpoints_accessible_without_token– unauthenticated GET → 200All pre-existing tests continue to pass unchanged under
AUTH_BACKEND=noauth.