Skip to content

Commit 4a11cc4

Browse files
[flutter_tools] do not validate maven upstream if cloud storage override provided (#98293)
1 parent e9f83cf commit 4a11cc4

2 files changed

Lines changed: 29 additions & 20 deletions

File tree

packages/flutter_tools/lib/src/http_host_validator.dart

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,21 @@ const String kDoctorHostTimeout = 'FLUTTER_DOCTOR_HOST_TIMEOUT';
1818
const String kPubDevHttpHost = 'https://pub.dev/';
1919
const String kgCloudHttpHost = 'https://cloud.google.com/';
2020

21-
/// Android specific required HTTP hosts.
22-
const List<String> androidRequiredHttpHosts = <String>[
23-
'https://maven.google.com/',
24-
];
25-
2621
/// MacOS specific required HTTP hosts.
2722
const List<String> macOSRequiredHttpHosts = <String>[
2823
'https://cocoapods.org/',
2924
];
3025

26+
/// Android specific required HTTP hosts.
27+
List<String> androidRequiredHttpHosts(Platform platform) {
28+
return <String>[
29+
// If kEnvCloudUrl is set, it will be used as the maven host
30+
if (!platform.environment.containsKey(kEnvCloudUrl))
31+
'https://maven.google.com/',
32+
];
33+
}
34+
35+
3136
// Validator that checks all provided hosts are reachable and responsive
3237
class HttpHostValidator extends DoctorValidator {
3338
HttpHostValidator(
@@ -49,7 +54,7 @@ class HttpHostValidator extends DoctorValidator {
4954

5055
List<String> get _requiredHosts => <String>[
5156
if (_featureFlags.isMacOSEnabled) ...macOSRequiredHttpHosts,
52-
if (_featureFlags.isAndroidEnabled) ...androidRequiredHttpHosts,
57+
if (_featureFlags.isAndroidEnabled) ...androidRequiredHttpHosts(_platform),
5358
_platform.environment[kEnvPubHostedUrl] ?? kPubDevHttpHost,
5459
_platform.environment[kEnvCloudUrl] ?? kgCloudHttpHost,
5560
];

packages/flutter_tools/test/commands.shard/hermetic/http_host_validator_test.dart

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ void main() {
4848
testWithoutContext('all http hosts are not available', () async {
4949
// Run the check for all operating systems one by one
5050
for(final String os in osTested) {
51+
final Platform platform = FakePlatform(operatingSystem: os);
5152
final HttpHostValidator httpHostValidator = HttpHostValidator(
52-
platform: FakePlatform(operatingSystem: os),
53+
platform: platform,
5354
featureFlags: TestFeatureFlags(),
5455
httpClient: FakeHttpClient.list(<FakeRequest>[
5556
FakeRequest(Uri.parse(kgCloudHttpHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
56-
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
57+
FakeRequest(Uri.parse(androidRequiredHttpHosts(platform)[0]), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
5758
FakeRequest(Uri.parse(kPubDevHttpHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
5859
FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
5960
]),
@@ -70,12 +71,13 @@ void main() {
7071
testWithoutContext('one http hosts are not available', () async {
7172
// Run the check for all operating systems one by one
7273
for(final String os in osTested) {
74+
final Platform platform = FakePlatform(operatingSystem: os);
7375
final HttpHostValidator httpHostValidator = HttpHostValidator(
74-
platform: FakePlatform(operatingSystem: os),
76+
platform: platform,
7577
featureFlags: TestFeatureFlags(),
7678
httpClient: FakeHttpClient.list(<FakeRequest>[
7779
FakeRequest(Uri.parse(kgCloudHttpHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
78-
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head),
80+
FakeRequest(Uri.parse(androidRequiredHttpHosts(platform)[0]), method: HttpMethod.head),
7981
FakeRequest(Uri.parse(kPubDevHttpHost), method: HttpMethod.head),
8082
FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head),
8183
]),
@@ -92,12 +94,13 @@ void main() {
9294
testWithoutContext('one http hosts are not available', () async {
9395
// Run the check for all operating systems one by one
9496
for(final String os in osTested) {
97+
final Platform platform = FakePlatform(operatingSystem: os);
9598
final HttpHostValidator httpHostValidator = HttpHostValidator(
96-
platform: FakePlatform(operatingSystem: os),
99+
platform: platform,
97100
featureFlags: TestFeatureFlags(),
98101
httpClient: FakeHttpClient.list(<FakeRequest>[
99102
FakeRequest(Uri.parse(kgCloudHttpHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
100-
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head),
103+
FakeRequest(Uri.parse(androidRequiredHttpHosts(platform)[0]), method: HttpMethod.head),
101104
FakeRequest(Uri.parse(kPubDevHttpHost), method: HttpMethod.head),
102105
FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head),
103106
]),
@@ -135,12 +138,12 @@ void main() {
135138
testWithoutContext('all http hosts are not available', () async {
136139
// Run the check for all operating systems one by one
137140
for(final String os in osTested) {
141+
final Platform platform = FakePlatform(operatingSystem: os, environment: kTestEnvironment);
138142
final HttpHostValidator httpHostValidator = HttpHostValidator(
139-
platform: FakePlatform(operatingSystem: os, environment: kTestEnvironment),
143+
platform: platform,
140144
featureFlags: TestFeatureFlags(),
141145
httpClient: FakeHttpClient.list(<FakeRequest>[
142146
FakeRequest(Uri.parse(kTestEnvGCloudHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
143-
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
144147
FakeRequest(Uri.parse(kTestEnvPubHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
145148
FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
146149
]),
@@ -157,12 +160,12 @@ void main() {
157160
testWithoutContext('one http hosts are not available', () async {
158161
// Run the check for all operating systems one by one
159162
for(final String os in osTested) {
163+
final Platform platform = FakePlatform(operatingSystem: os, environment: kTestEnvironment);
160164
final HttpHostValidator httpHostValidator = HttpHostValidator(
161-
platform: FakePlatform(operatingSystem: os, environment: kTestEnvironment),
165+
platform: platform,
162166
featureFlags: TestFeatureFlags(),
163167
httpClient: FakeHttpClient.list(<FakeRequest>[
164168
FakeRequest(Uri.parse(kTestEnvGCloudHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
165-
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head),
166169
FakeRequest(Uri.parse(kTestEnvPubHost), method: HttpMethod.head),
167170
FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head),
168171
]),
@@ -179,12 +182,12 @@ void main() {
179182
testWithoutContext('one http hosts are not available', () async {
180183
// Run the check for all operating systems one by one
181184
for(final String os in osTested) {
185+
final Platform platform = FakePlatform(operatingSystem: os, environment: kTestEnvironment);
182186
final HttpHostValidator httpHostValidator = HttpHostValidator(
183-
platform: FakePlatform(operatingSystem: os, environment: kTestEnvironment),
187+
platform: platform,
184188
featureFlags: TestFeatureFlags(),
185189
httpClient: FakeHttpClient.list(<FakeRequest>[
186190
FakeRequest(Uri.parse(kTestEnvGCloudHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
187-
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head),
188191
FakeRequest(Uri.parse(kTestEnvPubHost), method: HttpMethod.head),
189192
FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head),
190193
]),
@@ -224,13 +227,14 @@ void main() {
224227
testWithoutContext('all http hosts are available - iOS disabled', () async {
225228
// Run the check for all operating systems one by one
226229
for(final String os in osTested) {
230+
final Platform platform = FakePlatform(operatingSystem: os);
227231
final HttpHostValidator httpHostValidator = HttpHostValidator(
228-
platform: FakePlatform(operatingSystem: os),
232+
platform: platform,
229233
featureFlags: TestFeatureFlags(isIOSEnabled: false),
230234
httpClient: FakeHttpClient.list(<FakeRequest>[
231235
FakeRequest(Uri.parse(kgCloudHttpHost), method: HttpMethod.head),
232236
FakeRequest(Uri.parse(kPubDevHttpHost), method: HttpMethod.head),
233-
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head),
237+
FakeRequest(Uri.parse(androidRequiredHttpHosts(platform)[0]), method: HttpMethod.head),
234238
]),
235239
);
236240

0 commit comments

Comments
 (0)