Unverified Commit 4a11cc4b authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_tools] do not validate maven upstream if cloud storage override provided (#98293)

parent e9f83cf4
...@@ -18,16 +18,21 @@ const String kDoctorHostTimeout = 'FLUTTER_DOCTOR_HOST_TIMEOUT'; ...@@ -18,16 +18,21 @@ const String kDoctorHostTimeout = 'FLUTTER_DOCTOR_HOST_TIMEOUT';
const String kPubDevHttpHost = 'https://pub.dev/'; const String kPubDevHttpHost = 'https://pub.dev/';
const String kgCloudHttpHost = 'https://cloud.google.com/'; const String kgCloudHttpHost = 'https://cloud.google.com/';
/// Android specific required HTTP hosts.
const List<String> androidRequiredHttpHosts = <String>[
'https://maven.google.com/',
];
/// MacOS specific required HTTP hosts. /// MacOS specific required HTTP hosts.
const List<String> macOSRequiredHttpHosts = <String>[ const List<String> macOSRequiredHttpHosts = <String>[
'https://cocoapods.org/', 'https://cocoapods.org/',
]; ];
/// Android specific required HTTP hosts.
List<String> androidRequiredHttpHosts(Platform platform) {
return <String>[
// If kEnvCloudUrl is set, it will be used as the maven host
if (!platform.environment.containsKey(kEnvCloudUrl))
'https://maven.google.com/',
];
}
// Validator that checks all provided hosts are reachable and responsive // Validator that checks all provided hosts are reachable and responsive
class HttpHostValidator extends DoctorValidator { class HttpHostValidator extends DoctorValidator {
HttpHostValidator( HttpHostValidator(
...@@ -49,7 +54,7 @@ class HttpHostValidator extends DoctorValidator { ...@@ -49,7 +54,7 @@ class HttpHostValidator extends DoctorValidator {
List<String> get _requiredHosts => <String>[ List<String> get _requiredHosts => <String>[
if (_featureFlags.isMacOSEnabled) ...macOSRequiredHttpHosts, if (_featureFlags.isMacOSEnabled) ...macOSRequiredHttpHosts,
if (_featureFlags.isAndroidEnabled) ...androidRequiredHttpHosts, if (_featureFlags.isAndroidEnabled) ...androidRequiredHttpHosts(_platform),
_platform.environment[kEnvPubHostedUrl] ?? kPubDevHttpHost, _platform.environment[kEnvPubHostedUrl] ?? kPubDevHttpHost,
_platform.environment[kEnvCloudUrl] ?? kgCloudHttpHost, _platform.environment[kEnvCloudUrl] ?? kgCloudHttpHost,
]; ];
......
...@@ -48,12 +48,13 @@ void main() { ...@@ -48,12 +48,13 @@ void main() {
testWithoutContext('all http hosts are not available', () async { testWithoutContext('all http hosts are not available', () async {
// Run the check for all operating systems one by one // Run the check for all operating systems one by one
for(final String os in osTested) { for(final String os in osTested) {
final Platform platform = FakePlatform(operatingSystem: os);
final HttpHostValidator httpHostValidator = HttpHostValidator( final HttpHostValidator httpHostValidator = HttpHostValidator(
platform: FakePlatform(operatingSystem: os), platform: platform,
featureFlags: TestFeatureFlags(), featureFlags: TestFeatureFlags(),
httpClient: FakeHttpClient.list(<FakeRequest>[ httpClient: FakeHttpClient.list(<FakeRequest>[
FakeRequest(Uri.parse(kgCloudHttpHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)), FakeRequest(Uri.parse(kgCloudHttpHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)), FakeRequest(Uri.parse(androidRequiredHttpHosts(platform)[0]), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
FakeRequest(Uri.parse(kPubDevHttpHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)), FakeRequest(Uri.parse(kPubDevHttpHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)), FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
]), ]),
...@@ -70,12 +71,13 @@ void main() { ...@@ -70,12 +71,13 @@ void main() {
testWithoutContext('one http hosts are not available', () async { testWithoutContext('one http hosts are not available', () async {
// Run the check for all operating systems one by one // Run the check for all operating systems one by one
for(final String os in osTested) { for(final String os in osTested) {
final Platform platform = FakePlatform(operatingSystem: os);
final HttpHostValidator httpHostValidator = HttpHostValidator( final HttpHostValidator httpHostValidator = HttpHostValidator(
platform: FakePlatform(operatingSystem: os), platform: platform,
featureFlags: TestFeatureFlags(), featureFlags: TestFeatureFlags(),
httpClient: FakeHttpClient.list(<FakeRequest>[ httpClient: FakeHttpClient.list(<FakeRequest>[
FakeRequest(Uri.parse(kgCloudHttpHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)), FakeRequest(Uri.parse(kgCloudHttpHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head), FakeRequest(Uri.parse(androidRequiredHttpHosts(platform)[0]), method: HttpMethod.head),
FakeRequest(Uri.parse(kPubDevHttpHost), method: HttpMethod.head), FakeRequest(Uri.parse(kPubDevHttpHost), method: HttpMethod.head),
FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head), FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head),
]), ]),
...@@ -92,12 +94,13 @@ void main() { ...@@ -92,12 +94,13 @@ void main() {
testWithoutContext('one http hosts are not available', () async { testWithoutContext('one http hosts are not available', () async {
// Run the check for all operating systems one by one // Run the check for all operating systems one by one
for(final String os in osTested) { for(final String os in osTested) {
final Platform platform = FakePlatform(operatingSystem: os);
final HttpHostValidator httpHostValidator = HttpHostValidator( final HttpHostValidator httpHostValidator = HttpHostValidator(
platform: FakePlatform(operatingSystem: os), platform: platform,
featureFlags: TestFeatureFlags(), featureFlags: TestFeatureFlags(),
httpClient: FakeHttpClient.list(<FakeRequest>[ httpClient: FakeHttpClient.list(<FakeRequest>[
FakeRequest(Uri.parse(kgCloudHttpHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)), FakeRequest(Uri.parse(kgCloudHttpHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head), FakeRequest(Uri.parse(androidRequiredHttpHosts(platform)[0]), method: HttpMethod.head),
FakeRequest(Uri.parse(kPubDevHttpHost), method: HttpMethod.head), FakeRequest(Uri.parse(kPubDevHttpHost), method: HttpMethod.head),
FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head), FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head),
]), ]),
...@@ -135,12 +138,12 @@ void main() { ...@@ -135,12 +138,12 @@ void main() {
testWithoutContext('all http hosts are not available', () async { testWithoutContext('all http hosts are not available', () async {
// Run the check for all operating systems one by one // Run the check for all operating systems one by one
for(final String os in osTested) { for(final String os in osTested) {
final Platform platform = FakePlatform(operatingSystem: os, environment: kTestEnvironment);
final HttpHostValidator httpHostValidator = HttpHostValidator( final HttpHostValidator httpHostValidator = HttpHostValidator(
platform: FakePlatform(operatingSystem: os, environment: kTestEnvironment), platform: platform,
featureFlags: TestFeatureFlags(), featureFlags: TestFeatureFlags(),
httpClient: FakeHttpClient.list(<FakeRequest>[ httpClient: FakeHttpClient.list(<FakeRequest>[
FakeRequest(Uri.parse(kTestEnvGCloudHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)), FakeRequest(Uri.parse(kTestEnvGCloudHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
FakeRequest(Uri.parse(kTestEnvPubHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)), FakeRequest(Uri.parse(kTestEnvPubHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)), FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
]), ]),
...@@ -157,12 +160,12 @@ void main() { ...@@ -157,12 +160,12 @@ void main() {
testWithoutContext('one http hosts are not available', () async { testWithoutContext('one http hosts are not available', () async {
// Run the check for all operating systems one by one // Run the check for all operating systems one by one
for(final String os in osTested) { for(final String os in osTested) {
final Platform platform = FakePlatform(operatingSystem: os, environment: kTestEnvironment);
final HttpHostValidator httpHostValidator = HttpHostValidator( final HttpHostValidator httpHostValidator = HttpHostValidator(
platform: FakePlatform(operatingSystem: os, environment: kTestEnvironment), platform: platform,
featureFlags: TestFeatureFlags(), featureFlags: TestFeatureFlags(),
httpClient: FakeHttpClient.list(<FakeRequest>[ httpClient: FakeHttpClient.list(<FakeRequest>[
FakeRequest(Uri.parse(kTestEnvGCloudHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)), FakeRequest(Uri.parse(kTestEnvGCloudHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head),
FakeRequest(Uri.parse(kTestEnvPubHost), method: HttpMethod.head), FakeRequest(Uri.parse(kTestEnvPubHost), method: HttpMethod.head),
FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head), FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head),
]), ]),
...@@ -179,12 +182,12 @@ void main() { ...@@ -179,12 +182,12 @@ void main() {
testWithoutContext('one http hosts are not available', () async { testWithoutContext('one http hosts are not available', () async {
// Run the check for all operating systems one by one // Run the check for all operating systems one by one
for(final String os in osTested) { for(final String os in osTested) {
final Platform platform = FakePlatform(operatingSystem: os, environment: kTestEnvironment);
final HttpHostValidator httpHostValidator = HttpHostValidator( final HttpHostValidator httpHostValidator = HttpHostValidator(
platform: FakePlatform(operatingSystem: os, environment: kTestEnvironment), platform: platform,
featureFlags: TestFeatureFlags(), featureFlags: TestFeatureFlags(),
httpClient: FakeHttpClient.list(<FakeRequest>[ httpClient: FakeHttpClient.list(<FakeRequest>[
FakeRequest(Uri.parse(kTestEnvGCloudHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)), FakeRequest(Uri.parse(kTestEnvGCloudHost), method: HttpMethod.head, responseError: const OSError('Name or service not known', -2)),
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head),
FakeRequest(Uri.parse(kTestEnvPubHost), method: HttpMethod.head), FakeRequest(Uri.parse(kTestEnvPubHost), method: HttpMethod.head),
FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head), FakeRequest(Uri.parse(macOSRequiredHttpHosts[0]), method: HttpMethod.head),
]), ]),
...@@ -224,13 +227,14 @@ void main() { ...@@ -224,13 +227,14 @@ void main() {
testWithoutContext('all http hosts are available - iOS disabled', () async { testWithoutContext('all http hosts are available - iOS disabled', () async {
// Run the check for all operating systems one by one // Run the check for all operating systems one by one
for(final String os in osTested) { for(final String os in osTested) {
final Platform platform = FakePlatform(operatingSystem: os);
final HttpHostValidator httpHostValidator = HttpHostValidator( final HttpHostValidator httpHostValidator = HttpHostValidator(
platform: FakePlatform(operatingSystem: os), platform: platform,
featureFlags: TestFeatureFlags(isIOSEnabled: false), featureFlags: TestFeatureFlags(isIOSEnabled: false),
httpClient: FakeHttpClient.list(<FakeRequest>[ httpClient: FakeHttpClient.list(<FakeRequest>[
FakeRequest(Uri.parse(kgCloudHttpHost), method: HttpMethod.head), FakeRequest(Uri.parse(kgCloudHttpHost), method: HttpMethod.head),
FakeRequest(Uri.parse(kPubDevHttpHost), method: HttpMethod.head), FakeRequest(Uri.parse(kPubDevHttpHost), method: HttpMethod.head),
FakeRequest(Uri.parse(androidRequiredHttpHosts[0]), method: HttpMethod.head), FakeRequest(Uri.parse(androidRequiredHttpHosts(platform)[0]), method: HttpMethod.head),
]), ]),
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment