fix(signin): accept the cross-device redirect on each partition's sign-in host (#5557)

The cross-device redirect_uri was matched against the commercial
<region>.signin.aws.amazon.com only, so a login that resolved another
partition's Sign-In host was refused with invalid_request.

regen_partitions.py now reads botocore's signin endpoint ruleset and
vendors one signinHost per partition into aws/partitions.json. The
redirect is accepted on the Sign-In host of a region in the deployment's
partition, and another partition's host is refused. The device
authorization client ids keep their literals: the Sign-In model spells
them the same way in every partition.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-13 07:47:19 -04:00
1 parent 0d71894153
commit 1b7c79fd9e
10 files changed
+232 -30

No files matched your search

+5 -4
View File
@@ -107,6 +107,11 @@ back to `aws` for a label no partition publishes.
(`IllegalLocationConstraintException` otherwise). A China or GovCloud client must send the
constraint, which the AWS SDKs do; `GetBucketLocation` still answers an empty constraint only
for `us-east-1`, in every partition.
- **AWS Sign-In**: the cross-device login redirect is accepted on the Sign-In host of the
deployment's partition (`<region>.signin.amazonaws.cn` in China,
`<region>.signin.amazonaws-us-gov.com` in GovCloud), read from botocore's `signin` endpoint
ruleset into `aws/partitions.json`, and on Floci's own endpoint. The device-authorization client
ids are the same literal in every partition, as the Sign-In model spells them.
- **Hosted zones and console URLs**: load balancer and S3 website hosted zone ids come from a
per-region table (`aws/region-facts.json`, generated from the Terraform provider and the CDK,
which transcribe the AWS General Reference); Network load balancers have their own zone,
@@ -227,10 +232,6 @@ These values have no published source Floci can cite, so it does not guess them;
the commercial value or Floci's own base host until sourced:
- the China CloudFront distribution domain suffix (only the API host is published);
- the console cross-device sign-in redirect host outside the commercial partition: besides the
endpoint the authorize request arrived on, the only AWS host Floci accepts is
`<region>.signin.aws.amazon.com` (the device-authorization client ids themselves,
`arn:aws:signin:::devtools/...`, are the same in every partition);
- the STS web-identity audience outside the commercial partition;
- the EKS Pod Identity token audience (`pods.eks.amazonaws.com`) outside the commercial partition;
- the Lambda function-URL host outside the commercial partition;
+1 -1
View File
@@ -29,7 +29,7 @@ aws login --remote --endpoint-url http://localhost:4566 --region us-east-1
The CLI prints the authorize URL and waits for a code. After the consent page, Floci lands on
`/v1/sessions/confirmation` on the same endpoint, the path AWS Sign-In uses, and shows the
verification code to paste back. The redirect must point at the endpoint the request arrived on
or at an AWS Sign-In host; any other origin is refused.
or at the AWS Sign-In host of a region in the deployment's partition; any other origin is refused.
## Supported Actions
@@ -10,7 +10,7 @@ import java.util.regex.Pattern;
/**
* One AWS partition as AWS publishes it: {@code aws}, {@code aws-cn}, {@code aws-us-gov}, the
* classified {@code aws-iso*} family and {@code aws-eusc}. Every field is vendored from botocore's
* {@code partitions.json} and {@code endpoints.json} into {@code aws/partitions.json} by
* {@code partitions.json}, {@code endpoints.json} and endpoint rulesets into {@code aws/partitions.json} by
* {@code tools/aws/regen_partitions.py}; nothing here is hand-typed. See {@link AwsPartitions}
* for the catalog and the region-to-partition lookup.
*
@@ -30,6 +30,9 @@ import java.util.regex.Pattern;
* @param supportsDualStack whether the partition publishes dual-stack endpoints
* @param supportsFips whether the partition publishes FIPS endpoints
* @param s3DualStackRegions the regions whose S3 endpoint publishes a dual-stack variant
* @param signinHost the AWS Sign-In data-plane host with a {@code {region}} placeholder
* ({@code {region}.signin.amazonaws.cn}), or {@code null} where
* botocore's ruleset names none; its domain is not the DNS suffix
*/
public record AwsPartition(
String id,
@@ -44,7 +47,8 @@ public record AwsPartition(
Map<String, GlobalEndpoint> globalServices,
boolean supportsDualStack,
boolean supportsFips,
Set<String> s3DualStackRegions) {
Set<String> s3DualStackRegions,
String signinHost) {
/**
* A published region.
@@ -152,6 +156,11 @@ public record AwsPartition(
return id != null && regionRegex.matcher(id.trim().toLowerCase(Locale.ROOT)).matches();
}
/** The host AWS Sign-In's data plane is served on for {@code region}, when AWS publishes one. */
public Optional<String> signinHostname(String region) {
return Optional.ofNullable(signinHost).map(host -> host.replace("{region}", region));
}
/** The regional endpoint host, {@code <service>.<region>.<dnsSuffix>}. */
public String regionalHostname(String service, String region) {
return service + "." + region + "." + dnsSuffix;
@@ -313,7 +313,8 @@ public final class AwsPartitions {
globalServices,
node.path("supportsDualStack").asBoolean(false),
node.path("supportsFips").asBoolean(false),
s3DualStackRegions);
s3DualStackRegions,
node.path("signinHost").asText(null));
}
private static String required(JsonNode node, String field) {
@@ -2,6 +2,8 @@ package io.github.hectorvent.floci.services.signin;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.core.common.AwsPartition;
import io.github.hectorvent.floci.core.common.AwsPartitions;
import io.github.hectorvent.floci.core.common.Base64Url;
import io.github.hectorvent.floci.core.common.Digests;
import io.github.hectorvent.floci.core.common.RegionResolver;
@@ -37,10 +39,10 @@ import java.util.regex.Pattern;
@ApplicationScoped
public class SigninService {
// The console device-auth client ids as the commercial console spells them; no source says
// how the China or GovCloud consoles spell theirs, so they stay literal (see docs/configuration/partitions.md).
static final String SAME_DEVICE_CLIENT = "arn:aws:signin:::devtools/same-device"; // partition-literal: console client id, non-commercial spelling unknown
static final String CROSS_DEVICE_CLIENT = "arn:aws:signin:::devtools/cross-device"; // partition-literal: console client id, non-commercial spelling unknown
// The device-auth client ids are these literals in every partition: the Sign-In model's ClientId
// pattern is arn:aws:signin:::devtools/(cross-device|same-device), and the AWS CLI sends them as is.
static final String SAME_DEVICE_CLIENT = "arn:aws:signin:::devtools/same-device"; // partition-literal: the model's ClientId pattern, one spelling for every partition
static final String CROSS_DEVICE_CLIENT = "arn:aws:signin:::devtools/cross-device"; // partition-literal: the model's ClientId pattern, one spelling for every partition
static final String CONFIRMATION_PATH = "/v1/sessions/confirmation";
static final int ACCESS_TOKEN_TTL_SECONDS = 900;
private static final long AUTHORIZATION_CODE_TTL_SECONDS = 300;
@@ -52,8 +54,6 @@ public class SigninService {
private static final int MAX_REFRESH_TOKEN_LENGTH = 2048;
private static final int MAX_STATE_LENGTH = 128;
private static final Pattern PKCE_VALUE_PATTERN = Pattern.compile("[A-Za-z0-9._~-]{43,128}");
private static final Pattern AWS_SIGNIN_HOST_PATTERN =
Pattern.compile("[a-z]{2}-[a-z-]+-\\d+\\.signin\\.aws\\.amazon\\.com"); // partition-literal: console sign-in host, non-commercial host has no published source
private final IamService iamService;
private final RegionResolver regionResolver;
@@ -100,7 +100,7 @@ public class SigninService {
if (!"code".equals(responseType) || !"openid".equals(scope)) {
throw new SigninException("invalid_request", "response_type=code and scope=openid are required");
}
validateRedirectUri(clientId, redirectUri, requestOrigin);
validateRedirectUri(clientId, redirectUri, requestOrigin, AwsPartitions.byId(regionResolver.getPartition()));
if (state == null || state.isEmpty() || state.length() > MAX_STATE_LENGTH) {
throw new SigninException("invalid_request", "state must be 1-128 characters");
}
@@ -325,7 +325,8 @@ public class SigninService {
return value != null && PKCE_VALUE_PATTERN.matcher(value).matches();
}
private static void validateRedirectUri(String clientId, String redirectUri, URI requestOrigin) {
private static void validateRedirectUri(String clientId, String redirectUri, URI requestOrigin,
AwsPartition partition) {
if (redirectUri == null || redirectUri.isEmpty() || redirectUri.length() > MAX_REDIRECT_URI_LENGTH) {
throw new SigninException("invalid_request", "redirect_uri must be 1-2048 characters");
}
@@ -339,7 +340,7 @@ public class SigninService {
boolean valid = SAME_DEVICE_CLIENT.equals(clientId)
? isSameDeviceRedirect(uri)
: isCrossDeviceRedirect(uri) || isOwnConfirmationRedirect(uri, requestOrigin);
: isCrossDeviceRedirect(uri, partition) || isOwnConfirmationRedirect(uri, requestOrigin);
if (!valid) {
throw new SigninException("invalid_request", "redirect_uri is invalid for the AWS Sign-In client");
}
@@ -455,10 +456,9 @@ public class SigninService {
&& uri.getUserInfo() == null;
}
private static boolean isCrossDeviceRedirect(URI uri) {
private static boolean isCrossDeviceRedirect(URI uri, AwsPartition partition) {
return "https".equalsIgnoreCase(uri.getScheme())
&& uri.getHost() != null
&& AWS_SIGNIN_HOST_PATTERN.matcher(uri.getHost()).matches()
&& isSigninHost(uri.getHost(), partition)
&& uri.getPort() == -1
&& CONFIRMATION_PATH.equals(uri.getRawPath())
&& uri.getRawQuery() == null
@@ -466,6 +466,23 @@ public class SigninService {
&& uri.getUserInfo() == null;
}
/**
* True when {@code host} is the AWS Sign-In host of one of {@code partition}'s regions. The
* authorize request is an unsigned browser navigation, so the partition is the deployment's.
*/
private static boolean isSigninHost(String host, AwsPartition partition) {
if (host == null) {
return false;
}
int dot = host.indexOf('.');
if (dot <= 0) {
return false;
}
String region = host.substring(0, dot);
return (partition.isPublishedRegion(region) || partition.matchesRegionRegex(region))
&& partition.signinHostname(region).filter(host::equals).isPresent();
}
private static boolean isOwnConfirmationRedirect(URI uri, URI requestOrigin) {
return requestOrigin != null
&& uri.getScheme() != null
+16 -8
View File
@@ -833,7 +833,8 @@
"us-east-2",
"us-west-1",
"us-west-2"
]
],
"signinHost": "{region}.signin.aws.amazon.com"
},
{
"id": "aws-cn",
@@ -1071,7 +1072,8 @@
"s3DualStackRegions": [
"cn-north-1",
"cn-northwest-1"
]
],
"signinHost": "{region}.signin.amazonaws.cn"
},
{
"id": "aws-eusc",
@@ -1217,7 +1219,8 @@
"route53"
],
"globalServices": {},
"s3DualStackRegions": []
"s3DualStackRegions": [],
"signinHost": "{region}.signin.amazonaws-eusc.eu"
},
{
"id": "aws-iso",
@@ -1387,7 +1390,8 @@
"s3DualStackRegions": [
"us-iso-east-1",
"us-iso-west-1"
]
],
"signinHost": "{region}.signin.c2shome.ic.gov"
},
{
"id": "aws-iso-b",
@@ -1548,7 +1552,8 @@
},
"s3DualStackRegions": [
"us-isob-east-1"
]
],
"signinHost": "{region}.signin.sc2shome.sgov.gov"
},
{
"id": "aws-iso-e",
@@ -1682,7 +1687,8 @@
"regionalized": false
}
},
"s3DualStackRegions": []
"s3DualStackRegions": [],
"signinHost": "{region}.signin.csphome.adc-e.uk"
},
{
"id": "aws-iso-f",
@@ -1842,7 +1848,8 @@
"regionalized": false
}
},
"s3DualStackRegions": []
"s3DualStackRegions": [],
"signinHost": "{region}.signin.csphome.hci.ic.gov"
},
{
"id": "aws-us-gov",
@@ -2095,7 +2102,8 @@
"s3DualStackRegions": [
"us-gov-east-1",
"us-gov-west-1"
]
],
"signinHost": "{region}.signin.amazonaws-us-gov.com"
}
]
}
@@ -102,6 +102,21 @@ class AwsPartitionsTest {
}
/** botocore publishes no {@code aws-eusc-global}, and EUSC has no partition-wide service at all. */
@ParameterizedTest
@CsvSource({
"aws, us-east-1, us-east-1.signin.aws.amazon.com",
"aws-cn, cn-north-1, cn-north-1.signin.amazonaws.cn",
"aws-us-gov, us-gov-west-1, us-gov-west-1.signin.amazonaws-us-gov.com",
"aws-iso, us-iso-east-1, us-iso-east-1.signin.c2shome.ic.gov",
"aws-iso-b, us-isob-east-1, us-isob-east-1.signin.sc2shome.sgov.gov",
"aws-iso-e, eu-isoe-west-1, eu-isoe-west-1.signin.csphome.adc-e.uk",
"aws-iso-f, us-isof-south-1, us-isof-south-1.signin.csphome.hci.ic.gov",
"aws-eusc, eusc-de-east-1, eusc-de-east-1.signin.amazonaws-eusc.eu"
})
void everyPartitionPublishesItsSigninHost(String partition, String region, String host) {
assertEquals(Optional.of(host), AwsPartitions.byId(partition).signinHostname(region));
}
@Test
void euscHasNoPseudoRegionAndNoGlobalServices() {
AwsPartition eusc = AwsPartitions.byId("aws-eusc");
@@ -9,6 +9,8 @@ import io.github.hectorvent.floci.services.signin.model.TokenResult;
import io.github.hectorvent.floci.testing.MutableClock;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import java.net.URI;
import java.net.URLDecoder;
@@ -51,6 +53,7 @@ class SigninServiceTest {
private IamService iam;
private AtomicReference<String> accountId;
private AtomicReference<String> partition;
private MutableClock clock;
private SigninService service;
@@ -60,6 +63,8 @@ class SigninServiceTest {
RegionResolver region = mock(RegionResolver.class);
accountId = new AtomicReference<>(ACCOUNT_A);
when(region.getAccountId()).thenAnswer(ignored -> accountId.get());
partition = new AtomicReference<>("aws");
when(region.getPartition()).thenAnswer(ignored -> partition.get());
when(region.buildGlobalArn(anyString(), anyString(), anyString())).thenAnswer(invocation ->
"arn:aws:" + invocation.getArgument(0) + "::" + invocation.getArgument(1) + ":" + invocation.getArgument(2));
clock = new MutableClock();
@@ -136,6 +141,34 @@ class SigninServiceTest {
"http://localhost:4566/v1/sessions/confirmation", "code", "openid", "state", null, origin));
}
@ParameterizedTest
@CsvSource({
"aws, us-east-1.signin.aws.amazon.com",
"aws-cn, cn-north-1.signin.amazonaws.cn",
"aws-us-gov, us-gov-west-1.signin.amazonaws-us-gov.com",
"aws-iso, us-iso-east-1.signin.c2shome.ic.gov",
"aws-iso-b, us-isob-east-1.signin.sc2shome.sgov.gov",
"aws-iso-e, eu-isoe-west-1.signin.csphome.adc-e.uk",
"aws-iso-f, us-isof-south-1.signin.csphome.hci.ic.gov",
"aws-eusc, eusc-de-east-1.signin.amazonaws-eusc.eu"
})
void crossDeviceRedirectIsAcceptedOnTheDeploymentPartitionsSigninHostOnly(String deployment, String host) {
partition.set(deployment);
crossDeviceAuthorize("https://" + host + "/v1/sessions/confirmation", null);
String foreign = "aws".equals(deployment)
? "cn-north-1.signin.amazonaws.cn" : "us-east-1.signin.aws.amazon.com";
assertInvalidRequest(() -> crossDeviceAuthorize("https://" + foreign + "/v1/sessions/confirmation", null));
// A region of another partition on this partition's domain is not a host AWS serves.
String domain = host.substring(host.indexOf('.'));
String strayRegion = "aws".equals(deployment) ? "cn-north-1" : "us-east-1";
assertInvalidRequest(() -> crossDeviceAuthorize(
"https://" + strayRegion + domain + "/v1/sessions/confirmation", null));
assertInvalidRequest(() -> crossDeviceAuthorize("http://" + host + "/v1/sessions/confirmation", null));
assertInvalidRequest(() -> crossDeviceAuthorize("https://" + host + ":8443/v1/sessions/confirmation", null));
}
@Test
void verificationCodeIsTheBase64QueryTheCliDecodes() {
String verificationCode = service.verificationCode("the code/+", "state-1");
+64 -2
View File
@@ -28,6 +28,11 @@ from two sources and a rule:
`endpoints.json` omits some of those, so each partition's `services` adds them, recorded again
under `servicesFromRulesets`. Only a service `endpoints.json` lists in some partition is added:
a service it lists nowhere stays unknown everywhere rather than present in a few partitions.
- botocore's `signin` endpoint ruleset, for `signinHost`: the host AWS Sign-In's data plane is
served on in each partition (`{region}.signin.amazonaws.cn`), which no partition output can
build because the domain is not the DNS suffix. Only the plain branches count (no FIPS, no
dual-stack, not the control plane and not the OAuth endpoint); a partition the ruleset names in
none of them gets no `signinHost`.
- The AWS CDK's `region-info/lib/aws-entities.ts` (Apache-2.0), whose ordered region list
carries two rule markers: regions before `RULE_S3_WEBSITE_REGIONAL_SUBDOMAIN` use the
legacy `s3-website-<region>` endpoint form, and commercial regions after
@@ -247,11 +252,65 @@ def collect_ruleset_partitions(botocore_data: Path) -> dict[str, list[str]]:
return {prefix: sorted(partitions) for prefix, partitions in sorted(by_prefix.items())}
SIGNIN_SERVICE = "signin"
SIGNIN_URL_RE = re.compile(r"https://\{Region\}\.([a-z0-9-]+(?:\.[a-z0-9-]+)+)")
def boolean_condition(condition: dict) -> tuple[str, bool] | None:
"""The `(parameter, value)` a `booleanEquals(<parameter>, <literal>)` condition tests."""
if condition.get("fn") != "booleanEquals":
return None
argv = condition.get("argv", [])
if len(argv) != 2:
return None
for parameter, value in ((argv[0], argv[1]), (argv[1], argv[0])):
if isinstance(parameter, dict) and isinstance(parameter.get("ref"), str) and isinstance(value, bool):
return parameter["ref"], value
return None
def signin_hosts(rules: list[dict], inherited: tuple[dict, ...] = ()) -> dict[str, str]:
"""Partition id -> `{region}.signin.<domain>`, from the ruleset branches a plain data-plane
call resolves through: one partition named, FIPS and dual-stack both tested false, and a URL
that is the region followed by a literal domain. The control-plane and OAuth branches test
neither flag false, so they never match."""
hosts: dict[str, str] = {}
for rule in rules:
conditions = inherited + tuple(rule.get("conditions", []))
if rule.get("type") == "tree":
found = signin_hosts(rule.get("rules", []), conditions)
elif rule.get("type") == "endpoint":
url = rule.get("endpoint", {}).get("url")
match = SIGNIN_URL_RE.fullmatch(url) if isinstance(url, str) else None
named = {partition_name_condition(c) for c in conditions} - {None}
flags = dict(filter(None, (boolean_condition(c) for c in conditions)))
plain = flags.get("UseFIPS") is False and flags.get("UseDualStack") is False
found = {named.pop(): "{region}." + match.group(1)} if match and plain and len(named) == 1 else {}
else:
found = {}
for partition_id, host in found.items():
if hosts.setdefault(partition_id, host) != host:
raise ValueError(f"signin ruleset: {partition_id} resolves to both {hosts[partition_id]} and {host}")
return hosts
def collect_signin_hosts(botocore_data: Path) -> dict[str, str]:
"""Partition id -> AWS Sign-In data-plane host template, or {} when botocore has no model."""
service_dir = botocore_data / SIGNIN_SERVICE
if not service_dir.is_dir():
return {}
versions = sorted(v for v in service_dir.iterdir() if ruleset_file(v) is not None)
if not versions:
return {}
return signin_hosts(load_model(ruleset_file(versions[-1])).get("rules", []))
def build(partitions_doc: dict, endpoints_doc: dict, entities: list[str] | None,
carried: dict | None, provenance: str,
signing_names: dict[str, list[str]] | None = None,
rulesets: dict[str, list[str]] | None = None,
self_signed: set[str] | None = None) -> dict:
self_signed: set[str] | None = None,
signin: dict[str, str] | None = None) -> dict:
endpoint_partitions = {p["partition"]: p for p in endpoints_doc["partitions"]}
listed_anywhere = {service for p in endpoints_doc["partitions"] for service in p.get("services", {})}
if signing_names is not None and self_signed is not None:
@@ -335,6 +394,8 @@ def build(partitions_doc: dict, endpoints_doc: dict, entities: list[str] | None,
"globalServices": global_services,
"s3DualStackRegions": s3_dualstack_regions,
})
if partition_id in (signin or {}):
result_partitions[-1]["signinHost"] = signin[partition_id]
result_partitions.sort(key=lambda p: (p["id"] != COMMERCIAL, p["id"]))
return {
"_source": {
@@ -362,7 +423,8 @@ def generate(botocore_data: Path, provenance: str, cdk_root: Path | None, existi
entities = parse_cdk_entities((cdk_root / CDK_ENTITIES).read_text(encoding="utf-8"))
carried = load_json(existing) if existing.exists() else None
return build(partitions_doc, endpoints_doc, entities, carried, provenance, collect_signing_names(botocore_data),
collect_ruleset_partitions(botocore_data), collect_self_signed_prefixes(botocore_data))
collect_ruleset_partitions(botocore_data), collect_self_signed_prefixes(botocore_data),
collect_signin_hosts(botocore_data))
def main(argv: list[str] | None = None) -> int:
+56
View File
@@ -325,6 +325,62 @@ def test_build_adds_ruleset_partitions_only_for_services_endpoints_json_lists_so
assert by_id(document, "aws")["servicesFromRulesets"] == []
def flag_is(parameter, value):
return {"fn": "booleanEquals", "argv": [{"ref": parameter}, value]}
PLAIN = [flag_is("UseFIPS", False), flag_is("UseDualStack", False)]
def test_signin_hosts_reads_only_the_plain_data_plane_branches():
rules = [
{"type": "tree", "conditions": [flag_is("IsControlPlane", True)],
"rules": [endpoint_rule([partition_is("aws")], "https://signin.{Region}.api.aws")]},
endpoint_rule([flag_is("IsOAuthEndpoint", True), partition_is("aws")], "https://{Region}.oauth.signin.aws"),
endpoint_rule(PLAIN + [partition_is("aws")], "https://{Region}.signin.aws.amazon.com"),
endpoint_rule(PLAIN + [partition_is("aws-cn")], "https://{Region}.signin.amazonaws.cn"),
endpoint_rule([flag_is("UseFIPS", True), flag_is("UseDualStack", False), partition_is("aws-us-gov")],
"https://{Region}.signin-fips.amazonaws-us-gov.com"),
endpoint_rule(PLAIN, "https://{Region}.signin.{PartitionResult#dnsSuffix}"),
{"type": "error", "conditions": PLAIN + [partition_is("aws-iso")], "error": "not here"},
{"type": "tree", "conditions": [],
"rules": [{"type": "tree", "conditions": [partition_is("aws-eusc")],
"rules": [endpoint_rule(PLAIN, "https://{Region}.signin.amazonaws-eusc.eu"),
endpoint_rule([partition_is("aws")] + PLAIN, "https://{Region}.signin.aws.amazon.com")]}]},
]
assert r.signin_hosts(rules) == {
"aws": "{region}.signin.aws.amazon.com",
"aws-cn": "{region}.signin.amazonaws.cn",
"aws-eusc": "{region}.signin.amazonaws-eusc.eu",
}
def test_signin_hosts_refuses_two_hosts_for_one_partition():
rules = [endpoint_rule(PLAIN + [partition_is("aws")], "https://{Region}.signin.aws.amazon.com"),
endpoint_rule(PLAIN + [partition_is("aws")], "https://{Region}.signin.example.com")]
with pytest.raises(ValueError, match="aws resolves to both"):
r.signin_hosts(rules)
def test_collect_signin_hosts_reads_the_newest_gzipped_ruleset_or_nothing(tmp_path):
assert r.collect_signin_hosts(tmp_path) == {}
write_service(tmp_path, "signin", "2023-01-01", {"endpointPrefix": "signin"},
[endpoint_rule(PLAIN + [partition_is("aws-cn")], "https://{Region}.signin.amazonaws.cn")],
gzipped=True)
assert r.collect_signin_hosts(tmp_path) == {"aws-cn": "{region}.signin.amazonaws.cn"}
def test_build_adds_the_signin_host_only_where_one_is_known():
document = r.build(PARTITIONS, ENDPOINTS, r.parse_cdk_entities(ENTITIES), None, "test",
signin={"aws-cn": "{region}.signin.amazonaws.cn"})
assert by_id(document, "aws-cn")["signinHost"] == "{region}.signin.amazonaws.cn"
assert "signinHost" not in by_id(document, "aws")
def test_build_drops_a_signing_name_whose_own_prefix_service_is_listed_nowhere():
signing_names = {"execute-api": ["participant.connect"], "ecr": ["api.ecr"], "iam": ["iam-toolbox"]}
document = r.build(PARTITIONS, ENDPOINTS, r.parse_cdk_entities(ENTITIES), None, "test",