mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: remove unnecessary dbauthz.AsSystemRestricted calls in tests (#22663)
This commit is contained in:
@@ -8413,7 +8413,7 @@ func TestGetAuthenticatedWorkspaceAgentAndBuildByAuthToken_ShutdownScripts(t *te
|
||||
})
|
||||
|
||||
// Agent should still authenticate during stop build execution.
|
||||
row, err := db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(dbauthz.AsSystemRestricted(ctx), agent.AuthToken)
|
||||
row, err := db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(ctx, agent.AuthToken)
|
||||
require.NoError(t, err, "agent should authenticate during stop build execution")
|
||||
require.Equal(t, agent.ID, row.WorkspaceAgent.ID)
|
||||
require.Equal(t, startBuild.ID, row.WorkspaceBuild.ID, "should return start build, not stop build")
|
||||
@@ -8471,7 +8471,7 @@ func TestGetAuthenticatedWorkspaceAgentAndBuildByAuthToken_ShutdownScripts(t *te
|
||||
})
|
||||
|
||||
// Agent should NOT authenticate after stop job completes.
|
||||
_, err := db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(dbauthz.AsSystemRestricted(ctx), agent.AuthToken)
|
||||
_, err := db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(ctx, agent.AuthToken)
|
||||
require.ErrorIs(t, err, sql.ErrNoRows, "agent should not authenticate after stop job completes")
|
||||
})
|
||||
|
||||
@@ -8525,7 +8525,7 @@ func TestGetAuthenticatedWorkspaceAgentAndBuildByAuthToken_ShutdownScripts(t *te
|
||||
})
|
||||
|
||||
// Agent should NOT authenticate (start build failed).
|
||||
_, err := db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(dbauthz.AsSystemRestricted(ctx), agent.AuthToken)
|
||||
_, err := db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(ctx, agent.AuthToken)
|
||||
require.ErrorIs(t, err, sql.ErrNoRows, "agent from failed start build should not authenticate")
|
||||
})
|
||||
|
||||
@@ -8580,7 +8580,7 @@ func TestGetAuthenticatedWorkspaceAgentAndBuildByAuthToken_ShutdownScripts(t *te
|
||||
})
|
||||
|
||||
// Agent should authenticate during pending stop build.
|
||||
row, err := db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(dbauthz.AsSystemRestricted(ctx), agent.AuthToken)
|
||||
row, err := db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(ctx, agent.AuthToken)
|
||||
require.NoError(t, err, "agent should authenticate during pending stop build")
|
||||
require.Equal(t, agent.ID, row.WorkspaceAgent.ID)
|
||||
require.Equal(t, startBuild.ID, row.WorkspaceBuild.ID, "should return start build")
|
||||
@@ -8677,13 +8677,13 @@ func TestGetAuthenticatedWorkspaceAgentAndBuildByAuthToken_ShutdownScripts(t *te
|
||||
})
|
||||
|
||||
// Agent from build 3 should authenticate.
|
||||
row, err := db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(dbauthz.AsSystemRestricted(ctx), agent2.AuthToken)
|
||||
row, err := db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(ctx, agent2.AuthToken)
|
||||
require.NoError(t, err, "agent from most recent start should authenticate during stop")
|
||||
require.Equal(t, agent2.ID, row.WorkspaceAgent.ID)
|
||||
require.Equal(t, startBuild2.ID, row.WorkspaceBuild.ID)
|
||||
|
||||
// Agent from build 1 should NOT authenticate.
|
||||
_, err = db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(dbauthz.AsSystemRestricted(ctx), agent1.AuthToken)
|
||||
_, err = db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(ctx, agent1.AuthToken)
|
||||
require.ErrorIs(t, err, sql.ErrNoRows, "agent from old cycle should not authenticate")
|
||||
})
|
||||
|
||||
@@ -8737,7 +8737,7 @@ func TestGetAuthenticatedWorkspaceAgentAndBuildByAuthToken_ShutdownScripts(t *te
|
||||
})
|
||||
|
||||
// Agent from build 1 should NOT authenticate (latest is not STOP).
|
||||
_, err := db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(dbauthz.AsSystemRestricted(ctx), agent1.AuthToken)
|
||||
_, err := db.GetAuthenticatedWorkspaceAgentAndBuildByAuthToken(ctx, agent1.AuthToken)
|
||||
require.ErrorIs(t, err, sql.ErrNoRows, "agent should not authenticate when latest build is not STOP")
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user