From 791420ae1259a6bf2fd6a060c6e45df4b10a5331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 1 Oct 2024 10:55:51 +0200 Subject: [PATCH] cmd/cue: add more sanity checks for produced logins.json files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The following commit will resolve the TODO. Signed-off-by: Daniel Martí Change-Id: I9c3488f6d778854e9076860b4311448689fe7fc5 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202034 TryBot-Result: CUEcueckoo Unity-Result: CUE porcuepine Reviewed-by: Roger Peppe --- cmd/cue/cmd/testdata/script/login_immediate.txtar | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/cue/cmd/testdata/script/login_immediate.txtar b/cmd/cue/cmd/testdata/script/login_immediate.txtar index 26c0cf1d669..be276c112d4 100644 --- a/cmd/cue/cmd/testdata/script/login_immediate.txtar +++ b/cmd/cue/cmd/testdata/script/login_immediate.txtar @@ -6,4 +6,15 @@ oauthregistry immediate-success exec cue login stdout 'open:.*user_code=user-code' -grep 'secret-access-token' cueconfig/logins.json + +# Ensure that only one token is stored. +grep -count=1 '"registries": {' cueconfig/logins.json +grep -count=1 '"access_token"' cueconfig/logins.json + +# Ensure the contents of the token look correct. +grep -count=1 '"access_token": "secret-access-token"' cueconfig/logins.json +grep -count=1 '"token_type": "Bearer"' cueconfig/logins.json +# TODO(mvdan): oauthregistry does not provide expires_in correctly. +! grep '"expiry": ' cueconfig/logins.json +# oauthregistry does not give a refresh token, and we use encoding/json's omitempty. +! grep '"refresh_token"' cueconfig/logins.json