18b9d61e35
CI / build (pull_request) Successful in 20s
CI / lint (pull_request) Successful in 30s
CI / quality (pull_request) Successful in 42s
CI / helm (pull_request) Successful in 26s
CI / security (pull_request) Successful in 1m9s
CI / typecheck (pull_request) Successful in 3m59s
CI / benchmark-publish (pull_request) Has been skipped
CI / coverage (pull_request) Successful in 9m25s
CI / e2e_tests (pull_request) Successful in 17m19s
CI / integration_tests (pull_request) Successful in 21m10s
CI / unit_tests (pull_request) Successful in 6m0s
CI / docker (pull_request) Successful in 2m22s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Successful in 54m57s
Add content_hash(resource, *, algorithm='sha256') -> str to the ResourceHandler protocol and all handler implementations: - Protocol: new content_hash method on ResourceHandler (protocol.py) - BaseResourceHandler: default impl hashes file content or directory entry names; returns EMPTY_CONTENT_HASH sentinel for missing resources - GitCheckoutHandler: hashes git rev-parse HEAD through the requested algorithm for consistent digest format - FsDirectoryHandler: recursive walk hashing sorted relative paths and file contents (content-only, ignores metadata) - DevcontainerHandler: hashes devcontainer.json config file - DatabaseResourceHandler: hashes connection string; for SQLite file-based DBs, hashes the database file content - _DefaultHandler: delegates to BaseResourceHandler EMPTY_CONTENT_HASH sentinel is the SHA-256 of empty input (e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855). Hash algorithm is configurable via the algorithm parameter (default sha256, accepts any hashlib.new()-compatible name). Behave tests (10 scenarios): sentinel for missing/nonexistent, determinism, different content produces different hash, fs-directory recursive hash with change detection, git-checkout hash, configurable algorithm (sha256 vs sha512), protocol compliance for all 4 handlers. ISSUES CLOSED: #837
42 lines
2.1 KiB
Plaintext
42 lines
2.1 KiB
Plaintext
*** Settings ***
|
|
Documentation Integration tests for ResourceHandler content_hash method
|
|
Resource ${CURDIR}/common.resource
|
|
Suite Setup Setup Test Environment
|
|
Suite Teardown Cleanup Test Environment
|
|
|
|
*** Variables ***
|
|
${HELPER} ${CURDIR}/helper_resource_handler_content_hash.py
|
|
|
|
*** Test Cases ***
|
|
Content Hash Is Deterministic
|
|
[Documentation] Same file content produces same hash on repeated calls
|
|
${result}= Run Process ${PYTHON} ${HELPER} deterministic cwd=${WORKSPACE} on_timeout=kill timeout=30s
|
|
Log ${result.stdout}
|
|
Log ${result.stderr}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} deterministic-ok
|
|
|
|
Empty Resource Returns Sentinel Hash
|
|
[Documentation] Missing resource returns EMPTY_CONTENT_HASH sentinel
|
|
${result}= Run Process ${PYTHON} ${HELPER} empty-sentinel cwd=${WORKSPACE} on_timeout=kill timeout=30s
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} empty-sentinel-ok
|
|
|
|
Content Change Detected By Hash
|
|
[Documentation] Hash changes when file content is modified
|
|
${result}= Run Process ${PYTHON} ${HELPER} content-change-detection cwd=${WORKSPACE} on_timeout=kill timeout=30s
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} content-change-detection-ok
|
|
|
|
Configurable Hash Algorithm
|
|
[Documentation] SHA-256 and MD5 produce different-length hashes
|
|
${result}= Run Process ${PYTHON} ${HELPER} configurable-algorithm cwd=${WORKSPACE} on_timeout=kill timeout=30s
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} configurable-algorithm-ok
|
|
|
|
FsDirectory Recursive Hash
|
|
[Documentation] FsDirectoryHandler hashes directory contents recursively
|
|
${result}= Run Process ${PYTHON} ${HELPER} fs-directory-recursive cwd=${WORKSPACE} on_timeout=kill timeout=30s
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
Should Contain ${result.stdout} fs-directory-recursive-ok
|