Skip to content

chore(enterprise/cli): fix test flake in TestServerDBCrypt #10222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions enterprise/cli/server_dbcrypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestServerDBCrypt(t *testing.T) {
inv.Stdout = pty.Output()
err = inv.Run()
require.NoError(t, err)
require.NoError(t, pty.Close())

// Validate that all existing data has been encrypted with cipher A.
for _, usr := range users {
Expand All @@ -101,6 +102,7 @@ func TestServerDBCrypt(t *testing.T) {
inv.Stdout = pty.Output()
err = inv.Run()
require.NoError(t, err)
require.NoError(t, pty.Close())

// Validate that all data has been re-encrypted with cipher B.
for _, usr := range users {
Expand Down Expand Up @@ -142,6 +144,7 @@ func TestServerDBCrypt(t *testing.T) {
inv.Stdout = pty.Output()
err = inv.Run()
require.NoError(t, err)
require.NoError(t, pty.Close())

// Validate that both keys have been revoked.
keys, err = db.GetDBCryptKeys(ctx)
Expand Down Expand Up @@ -172,6 +175,7 @@ func TestServerDBCrypt(t *testing.T) {
inv.Stdout = pty.Output()
err = inv.Run()
require.NoError(t, err)
require.NoError(t, pty.Close())

// Validate that all data has been re-encrypted with cipher C.
for _, usr := range users {
Expand All @@ -189,6 +193,7 @@ func TestServerDBCrypt(t *testing.T) {
inv.Stdout = pty.Output()
err = inv.Run()
require.NoError(t, err)
require.NoError(t, pty.Close())

// Assert that no user links remain.
for _, usr := range users {
Expand Down Expand Up @@ -217,7 +222,10 @@ func genData(t *testing.T, db database.Store) []database.User {
for _, status := range database.AllUserStatusValues() {
for _, loginType := range database.AllLoginTypeValues() {
for _, deleted := range []bool{false, true} {
randName := mustString(t, 32)
usr := dbgen.User(t, db, database.User{
Username: randName,
Email: randName + "@notcoder.com",
LoginType: loginType,
Status: status,
Deleted: deleted,
Expand Down