From 67098119bba70c83485134773ec2c68b53abd568 Mon Sep 17 00:00:00 2001 From: Matt Ellis Date: Thu, 21 Nov 2024 14:30:19 -0800 Subject: [PATCH] tests: Re-enable tests disabled against #4341 (#4563) We should be able to re-enable the tests now. The one exception is the `azd login` test that validated login with a long lived client secret, since we no longer have a service principal with a long lived client secret. We'll have to make due without the end to end coverage here - but in practice we have good coverage at the unit test level of much of the code here, so we should be okay. Contributes To #4564 --- cli/azd/test/functional/cli_test.go | 4 +- .../test/functional/deployment_stacks_test.go | 2 - cli/azd/test/functional/login_test.go | 41 ------------------- 3 files changed, 1 insertion(+), 46 deletions(-) diff --git a/cli/azd/test/functional/cli_test.go b/cli/azd/test/functional/cli_test.go index b9e82b73d27..741d93d3aae 100644 --- a/cli/azd/test/functional/cli_test.go +++ b/cli/azd/test/functional/cli_test.go @@ -785,8 +785,6 @@ func newTestContext(t *testing.T) (context.Context, context.CancelFunc) { } func Test_CLI_InfraCreateAndDeleteResourceTerraform(t *testing.T) { - t.Skip("azure/azure-dev#4341") - // running this test in parallel is ok as it uses a t.TempDir() t.Parallel() ctx, cancel := newTestContext(t) @@ -828,7 +826,7 @@ func Test_CLI_InfraCreateAndDeleteResourceTerraform(t *testing.T) { } func Test_CLI_InfraCreateAndDeleteResourceTerraformRemote(t *testing.T) { - t.Skip("azure/azure-dev#4341") + t.Skip("azure/azure-dev#4564") ctx, cancel := newTestContext(t) defer cancel() diff --git a/cli/azd/test/functional/deployment_stacks_test.go b/cli/azd/test/functional/deployment_stacks_test.go index cabaf4a61de..152ac0559df 100644 --- a/cli/azd/test/functional/deployment_stacks_test.go +++ b/cli/azd/test/functional/deployment_stacks_test.go @@ -18,8 +18,6 @@ import ( ) func Test_DeploymentStacks(t *testing.T) { - t.Skip("azure/azure-dev#4341") - t.Run("Subscription_Scope_Up_Down", func(t *testing.T) { t.Parallel() ctx, cancel := newTestContext(t) diff --git a/cli/azd/test/functional/login_test.go b/cli/azd/test/functional/login_test.go index 0fbd97f46b4..56f9e6195f4 100644 --- a/cli/azd/test/functional/login_test.go +++ b/cli/azd/test/functional/login_test.go @@ -53,47 +53,6 @@ func Test_CLI_AuthLoginStatus(t *testing.T) { } } -func Test_CLI_LoginServicePrincipal(t *testing.T) { - t.Skip("azure/azure-dev#4341") - - ctx, cancel := newTestContext(t) - defer cancel() - - dir := t.TempDir() - - cli := azdcli.NewCLI(t) - // Isolate login to a separate configuration directory - cli.Env = append(cli.Env, "AZD_CONFIG_DIR="+dir) - if cfg.ClientID == "" || cfg.TenantID == "" /* || cfg.ClientSecret == "" */ { - if cfg.CI { - panic("Service principal is not configured. AZD_TEST_* variables are required to be set for live testing.") - } - - t.Skip("Skipping test because service principal is not configured. " + - "Set the relevant AZD_TEST_* variables to run this test.") - return - } - - loginState := loginStatus(t, ctx, cli) - require.Equal(t, contracts.LoginStatusUnauthenticated, loginState.Status) - - _, err := cli.RunCommand(ctx, - "auth", "login", - "--client-id", cfg.ClientID, - // "--client-secret", cfg.ClientSecret, - "--tenant-id", cfg.TenantID) - require.NoError(t, err) - - loginState = loginStatus(t, ctx, cli) - require.Equal(t, contracts.LoginStatusSuccess, loginState.Status) - - _, err = cli.RunCommand(ctx, "auth", "logout") - require.NoError(t, err) - - loginState = loginStatus(t, ctx, cli) - require.Equal(t, contracts.LoginStatusUnauthenticated, loginState.Status) -} - func loginStatus(t *testing.T, ctx context.Context, cli *azdcli.CLI) contracts.LoginResult { result, err := cli.RunCommand(ctx, "auth", "login", "--check-status", "--output", "json") require.NoError(t, err)