feat: log when SHOREBIRD_TOKEN is detected and successfully parsed (#2885)

This commit is contained in:
Bryan Oltman
2025-02-12 16:23:18 -05:00
committed by GitHub
parent 6165180920
commit 0fe46b2382
2 changed files with 14 additions and 0 deletions
@@ -315,6 +315,8 @@ class Auth {
void _loadCredentials() {
final envToken = platform.environment[shorebirdTokenEnvVar];
if (envToken != null) {
logger.info('$shorebirdTokenEnvVar detected');
try {
_token = CiToken.fromBase64(envToken.trim());
} on FormatException catch (e) {
@@ -328,6 +330,8 @@ Please regenerate using `shorebird login:ci`, update the $shorebirdTokenEnvVar e
..detail(e.toString());
rethrow;
}
logger.info('$shorebirdTokenEnvVar successfully parsed');
return;
}
@@ -541,6 +541,9 @@ void main() {
test('logs and throws error when token string is not valid base64',
() async {
expect(buildAuth, throwsA(isFormatException));
verify(
() => logger.info('$shorebirdTokenEnvVar detected'),
).called(1);
verify(
() => logger.err(
'''
@@ -549,6 +552,9 @@ Failed to parse CI token from environment. This likely means that your CI token
Please regenerate using `shorebird login:ci`, update the $shorebirdTokenEnvVar environment variable, and try again.''',
),
).called(1);
verifyNever(
() => logger.info('$shorebirdTokenEnvVar successfully parsed'),
);
});
});
@@ -588,6 +594,10 @@ Please regenerate using `shorebird login:ci`, update the $shorebirdTokenEnvVar e
final client = auth.client;
expect(client, isA<http.Client>());
expect(client, isA<AuthenticatedClient>());
verify(() => logger.info('$shorebirdTokenEnvVar detected')).called(1);
verify(
() => logger.info('$shorebirdTokenEnvVar successfully parsed'),
).called(1);
});
test('returns a plain http client when credentials are not present.',