MCPcopy Create free account
hub / github.com/Scalingo/cli / TestExistingAuth

Function TestExistingAuth

config/auth_test.go:43–71  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestExistingAuth(t *testing.T) {
44 ctx := t.Context()
45 u := &scalingo.User{
46 Email: "test@example.com",
47 Username: "test",
48 }
49 authenticator := &CliAuthenticator{}
50
51 // Before any auth
52 currentAuth, err := existingAuth(ctx)
53 require.NoError(t, err)
54
55 var configPerHost auth.ConfigPerHostV2
56 json.Unmarshal(currentAuth.AuthConfigPerHost, &configPerHost)
57 assert.Empty(t, configPerHost)
58 assert.True(t, currentAuth.LastUpdate.IsZero())
59
60 // After one auth
61 err = authenticator.StoreAuth(ctx, u, "0123456789")
62 require.NoError(t, err)
63
64 currentAuth, err = existingAuth(ctx)
65 json.Unmarshal(currentAuth.AuthConfigPerHost, &configPerHost)
66 require.NoError(t, err)
67 assert.Len(t, configPerHost, 1)
68 assert.False(t, currentAuth.LastUpdate.IsZero())
69
70 clean()
71}

Callers

nothing calls this directly

Calls 3

StoreAuthMethod · 0.95
existingAuthFunction · 0.85
cleanFunction · 0.85

Tested by

no test coverage detected