Skip to content

test: cover Locale.ROOT lowercasing paths from #1086 - #1225

Open
pjfanning wants to merge 1 commit into
apache:mainfrom
pjfanning:test/turkish-i-coverage
Open

test: cover Locale.ROOT lowercasing paths from #1086#1225
pjfanning wants to merge 1 commit into
apache:mainfrom
pjfanning:test/turkish-i-coverage

Conversation

@pjfanning

Copy link
Copy Markdown
Member

Motivation

#1086 moved a dozen call sites to Locale.ROOT but landed without tests. On main today the only turkish-i coverage is the HttpCharsets case in TurkishISpec, and nothing exercises the two directives that were fixed, so a regression would only surface for users running with a turkish default locale.

Two gaps worth calling out:

  • The obvious Uri test does not actually cover the fixed code. Uri("IPP://example.com") passes even against pre-use Locale.ROOT for toLowerCase/toUpperCase #1086 code, because the string parser lowercases the scheme through the ASCII-only CharUtils.toLowerCase in UriParser.appendLowered and never reaches Uri.normalizeScheme. The test here uses Uri(scheme = "IPP", authority = ...), which does go through normalizeScheme.
  • headerValueByName and overrideMethodWithParameter live in the http module, so they need a spec outside http-core.

Modification

  • TurkishISpec (http-core): four new cases under a tr-TR default locale covering HttpHeader.parse, Uri scheme normalization, MediaTypes.forExtension and ErrorInfo.withErrorHeaderName.
  • New TurkishLocaleDirectivesSpec (http-tests): covers headerValueByName("If-Match") and overrideMethodWithParameter with _method=options ("options".toUpperCase under tr-TR is OPTİONS, which used to yield 501 Not Implemented).

Both specs restore the previous default locale in a finally. Test-only change; no production code is touched.

Result

The paths #1086 fixed are pinned, and the same cases are available to check backports against.

Tests

References

Refs #1086, Refs #1224

Motivation:
apache#1086 switched a dozen call sites to Locale.ROOT but landed without tests, so
TurkishISpec still only covers HttpCharsets and nothing exercises the directives.
A regression in any of these paths would only show up for users running with a
turkish default locale.

Modification:
Extend TurkishISpec with cases for `HttpHeader.parse`, `Uri` scheme
normalization, `MediaTypes.forExtension` and `ErrorInfo.withErrorHeaderName`.
Add TurkishLocaleDirectivesSpec covering `headerValueByName` and
`overrideMethodWithParameter`, which live in the http module.

Result:
The header-name, scheme, file-extension, error-header-name, header-directive and
method-override paths are pinned against locale sensitive case conversion.

Tests:
- sbt "http-core / Test / testOnly org.apache.pekko.http.scaladsl.model.TurkishISpec" - 5 passed
- sbt "http-tests / Test / testOnly org.apache.pekko.http.scaladsl.server.directives.TurkishLocaleDirectivesSpec" - 2 passed; both fail when the two directives are reverted to default-locale case conversion
- sbt headerCreateAll - added the Apache header to the new file
- scalafmt --mode diff-ref=upstream/main - clean

References:
Refs apache#1086
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant