Validate Authorization header in Azure test fixture#111242
Validate Authorization header in Azure test fixture#111242DaveCTurner merged 2 commits intoelastic:mainfrom
Authorization header in Azure test fixture#111242Conversation
Today the Azure test fixture accepts all requests, but we should be checking that the `Authorization` header is at least present and approximately correct. This commit adds support for this check.
|
Pinging @elastic/es-distributed (Team:Distributed) |
DiannaHohensee
left a comment
There was a problem hiding this comment.
Unfamiliar with this code, so I have some questions, mostly.
|
|
||
| AzureBlobStoreHttpHandler(final String account, final String container) { | ||
| super(account, container); | ||
| super(account, container, null /* no auth header validation */); |
There was a problem hiding this comment.
might help to explain why we don't want to do header validation here?
| final var authHeader = getAuthHeader(exchange); | ||
| if (authHeader == null) { | ||
| return false; | ||
| } | ||
|
|
||
| if (authHeader.size() != 1) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
So it's OK to not have a header predicate, but it is not OK to skip sending one? What are these decisions based on 🤔
| @Override | ||
| public void handle(final HttpExchange exchange) throws IOException { | ||
| if (isValidAuthHeader(exchange) == false) { | ||
| try (exchange; var xcb = XContentBuilder.builder(XContentType.JSON.xContent())) { |
There was a problem hiding this comment.
I'd understand 'builder' more rapidly than discerning what 'xcb' stands for, my two cents.
| AZURE_TEST_ACCOUNT, | ||
| AZURE_TEST_CONTAINER | ||
| AZURE_TEST_CONTAINER, | ||
| AzureHttpFixture.startsWithPredicate("SharedKey " + AZURE_TEST_ACCOUNT + ":") |
There was a problem hiding this comment.
where do the headers get generated that we're trying to match here by expecting "SharedKey ....:"?
|
Oh, looks like Mikhail took care of this before I finished. Cool 👍 |
Arising from a post-merge review of elastic#111242
|
Thanks @DiannaHohensee, you raise valid points, we can continue to iterate on them in #111252. |
* main: (39 commits) Update README.asciidoc (elastic#111244) ESQL: INLINESTATS (elastic#109583) ESQL: Document a little of `DataType` (elastic#111250) Relax assertions in segment level field stats (elastic#111243) LogsDB data generator - support nested object field (elastic#111206) Validate `Authorization` header in Azure test fixture (elastic#111242) Fixing HistoryStoreTests.testPut() and testStoreWithHideSecrets() (elastic#111246) [ESQL] Remove Named Expcted Types map from testing infrastructure (elastic#111213) Change visibility of createWriter to allow tests from a different package to override it (elastic#111234) [ES|QL] Remove EsqlDataTypes (elastic#111089) Mute org.elasticsearch.repositories.azure.AzureBlobContainerRetriesTests testReadNonexistentBlobThrowsNoSuchFileException elastic#111233 Abstract codec lookup by name, to make CodecService extensible (elastic#111007) Add HTTPS support to `AzureHttpFixture` (elastic#111228) Unmuting tests related to free_context action being processed in ESSingleNodeTestCase (elastic#111224) Upgrade Azure SDK (elastic#111225) Collapse transport versions for 8.14.0 (elastic#111199) Make sure contender uses logs templates (elastic#111183) unmute HistogramPercentileAggregationTests.testBoxplotHistogram (elastic#111223) Refactor Quality Assurance test infrastructure (elastic#111195) Mute org.elasticsearch.xpack.restart.FullClusterRestartIT testDisableFieldNameField {cluster=UPGRADED} elastic#111222 ... # Conflicts: # server/src/main/java/org/elasticsearch/TransportVersions.java
Arising from a post-merge review of #111242
Today the Azure test fixture accepts all requests, but we should be
checking that the
Authorizationheader is at least present andapproximately correct. This commit adds support for this check.