Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Sovereign, high-performance data protection

Test coverage

This page lists which parts of the Google Workspace CSE support are exercised by automated tests, and which are not. It covers the KACLS endpoints served by the KMS (/google_cse/*) and the ckms google commands.

All the tests marked Offline run in a plain cargo test: they need no Google account, no Google network access and none of the CI secrets. Only one test needs real Google credentials.

Running the tests

ScopeCommandCredentials
Server endpoints, token validation, crypto, startupcargo test -p cosmian_kms_server google_csenone
ckms google commands (clap actions)cargo test -p cosmian_kms_cli_actions --features non-fips google_cmdnone
ckms google through the ckms binarycargo test -p ckms --features non-fips google_cmdnone
All of the above, plus the real Google token testmise run test:google-cseThe real Google test needs TEST_GOOGLE_OAUTH_CLIENT_ID, TEST_GOOGLE_OAUTH_CLIENT_SECRET and TEST_GOOGLE_OAUTH_REFRESH_TOKEN (CI only); without them it is skipped with a warning, and fails when CI is set

Server endpoints

The tests use a local identity provider: tokens are signed with a locally generated RSA key and the JWKS is loaded in memory. Endpoints are tested through the real Actix HTTP stack.

EndpointOffline coverageGap
GET /google_cse/statusResponse fields, kacls_url built from kms_public_url, missing kms_public_urlnone
GET /google_cse/certsJWK content, kid equals the one in create_jwt tokens, signature verified by the production signed-token validation, failure when the public key is destroyednone
POST /google_cse/wrap and /unwrapRound trip, google_email over email, case-insensitive email match, email mismatch, missing email, unknown signing key, garbage token, wrong resource_name, bad base64, truncated and tampered wrapped keysnone
POST /google_cse/digestHash equals compute_resource_key_hash for an empty perimeter, migration verifier authorization token, missing emailnone
POST /google_cse/privilegedwrap and /privilegedunwrapRound trip, Drive audience check, wrong resource_name, migration token issued by another KACLS, real loopback HTTP request from the new KACLS to the original KACLSnone
POST /google_cse/privatekeysignSHA256withRSA, SHA512withRSA, SHA256withRSA/PSS, SHA512withRSA/PSS with PKCS#1 and PKCS#8 keys (FIPS and non-FIPS), SHA-1 variants (non-FIPS only), rsa_pss_salt_length, unknown algorithm, bad digestnone
POST /google_cse/privatekeydecryptPKCS#1 v1.5 and OAEP (SHA-1, SHA-256, SHA-512) with PKCS#1 and PKCS#8 keys, OAEP label, unknown algorithm, bad ciphertext, bad base64The end-to-end create-pair flow with a PKCS#12 certificate (pkcs12_certify) runs only with --features non-fips
POST /google_cse/privilegedprivatekeydecryptSame algorithm matrix (PKCS#1 key), SPKI hash mismatch, unknown SPKI hash algorithmPKCS#8 wrapped keys are not accepted by this endpoint
POST /google_cse/rewrapTwo-KACLS DEK migration: outbound privilegedunwrap, re-wrap, hash, rejection, bad source URL, missing emailProduction-handler success: the SSRF guard rejects offline loopback targets
POST /google_cse/wrapprivatekeynoneNot implemented: the handler returns an empty 200
POST /google_cse/delegatenoneNot implemented: the handler returns an empty 200

Token validation

CheckOffline coverageGap
Authorization token: signature, kid, issuer, audience, crit, nested JWT, empty and malformed tokensCoverednone
Role, resource_name and kacls_url checks, audience post-checkCovered by unit tests of the extracted helpersThe helpers are compiled out of the insecure feature; the wiring in release builds is not run end to end
Authentication token signatureCovered through the production signed-token validation on the /certs keyIn test builds the authentication token is decoded without signature check, so HTTP tests do not verify it
Token expiry (exp)noneDisabled in test builds
Real Google-issued tokens and Google JWKSroutes::google_cse::jwt::tests::test_wrap_authNeeds the CI credentials; the only ignored server test

Server startup and configuration

AreaOffline coverageGap
google_cse_rsa key pair: generation, reuse, import from google_cse_migration_key, invalid PEMCoveredThe UNIQUE constraint race branch
JWKS URIs and issuers: defaults, whitelist, KMS_GOOGLE_CSE_<APP>_JWKS_URI, KMS_GOOGLE_CSE_<APP>_JWT_ISSUER, KMS_GOOGLE_CSE_AUDIENCECoverednone

ckms google commands

The Gmail API is replaced by a local mock server: the token endpoint comes from token_uri and the API base URL from the optional gmail_api_base_url field of gmail_api_conf.

CommandOffline coverageGap
google key-pairs createAll certificate options (extensions, existing certificate, PKCS#12), --dry-run, push to Gmail with the expected PKCS#7 and KACLS metadata, Gmail error, existing RSA key, invalid key id (non-private key, no linked public key)These tests run only with --features non-fips: a FIPS cargo test does not cover create
google key-pairs get, list, enable, disable, obliterateHTTP method, path, bearer tokennone
google identities get, list, insert, delete, patchHTTP method, path, body, bearer tokennone
Gmail clientOAuth token request, token endpoint error, non-JSON token response, invalid service-account key, Gmail error with and without JSON body, missing gmail_api_confThe real Gmail API contract is not tested
ckms binary dispatchidentities list, key-pairs list, key-pairs get errorRuns only with --features non-fips. The other subcommands are covered at the clap level only
HSM-backed CSE (using_hsm.rs)noneIgnored: needs a Utimaco HSM and Google credentials

Compliance of the simulated Google payloads

The tests build the requests and tokens Google would send. They follow Google's CSE API reference:

PayloadWhat the tests use
Docs, Drive, Calendar and Meet authorization tokenIssuer gsuitecse-tokenissuer-drive@system.gserviceaccount.com, audience cse-authorization, claims email, role, resource_name, perimeter_id, kacls_url, iat, exp; roles writer (wrap), reader (unwrap)
Gmail authorization tokenIssuer gsuitecse-tokenissuer-gmail@system.gserviceaccount.com, claims message_id, resource_name, spki_hash (base64 SHA-256 of the DER public key), spki_hash_algorithm, kacls_url; roles signer (privatekeysign), decrypter (privatekeydecrypt)
Migration authorization tokenRoles migrator (rewrap) and verifier (digest)
Authentication tokenIdP issuer, aud, email and the optional google_email
KACLS migration JWT (privilegedunwrap)iss is the URL of the requesting KACLS, kacls_url is the URL of the KACLS decrypting the data, audience kacls-migration, keys published at <iss>/certs
Request bodiesExact field names of each endpoint; reason and perimeter_id are optional and a test omits them; rsa_oaep_label is base64-encoded
Wrapped private keyAES-GCM nonce || ciphertext || tag without additional data, created like ckms google key-pairs create does

Deliberate differences from the reference:

  • exp and iat are numbers, as RFC 7519 requires, although the reference tables list them as strings.
  • /status also returns kacls_url, a Cosmian extension used by the CLI and the web UI.
  • Tests that disable token validation send placeholder tokens: they are ignored by the server.
  • One fixture captured from a real Gmail token also carries the kacls_owner_domain claim.

Known gaps

  • wrapprivatekey and delegate are not implemented, so they are not tested.
  • digest and rewrap always validate the authorization token, even when google_cse_disable_tokens_validation is set.
  • Production-handler rewrap success cannot use loopback offline because its SSRF guard rejects it; injected-client migration logic is covered.
  • Real Google tokens are validated by one test, which runs only in the upstream CI.
  • In a FIPS build the SHA-1 signatures, the key-pairs create tests, the ckms binary tests and the PKCS#12 create-pair test are not run.