Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Mayursinh Sarvaiya <[email protected]>
  • Loading branch information
Marvin9 committed Jan 8, 2025
1 parent b73e927 commit 2faf24f
Showing 1 changed file with 108 additions and 0 deletions.
108 changes: 108 additions & 0 deletions internal/api/create_credentials_v1alpha1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,114 @@ func TestCreateCredentials(t *testing.T) {
assert.Equal(t, "password", string(d[libCreds.FieldPassword]))
})

t.Run("validate credentials", func(t *testing.T) {
t.Parallel()

invalidCreds := specificCredentials{
project: "",
name: "test",
credType: "git",
repoURL: "abc",
username: "test",
password: "test",
}

err := s.validateCredentials(invalidCreds)

require.Error(t, err)

invalidCreds = specificCredentials{
project: "kargo-demo",
name: "",
credType: "git",
repoURL: "abc",
username: "test",
password: "test",
}

err = s.validateCredentials(invalidCreds)

require.Error(t, err)

invalidCreds = specificCredentials{
project: "kargo-demo",
name: "test",
credType: "",
repoURL: "abc",
username: "test",
password: "test",
}

err = s.validateCredentials(invalidCreds)

require.Error(t, err)

invalidCreds = specificCredentials{
project: "kargo-demo",
name: "test",
credType: "invalid",
repoURL: "abc",
username: "test",
password: "test",
}

err = s.validateCredentials(invalidCreds)

require.Error(t, err)

invalidCreds = specificCredentials{
project: "kargo-demo",
name: "test",
credType: "git",
repoURL: "",
username: "test",
password: "test",
}

err = s.validateCredentials(invalidCreds)

require.Error(t, err)

invalidCreds = specificCredentials{
project: "kargo-demo",
name: "test",
credType: "git",
repoURL: "https://github.com/akuity/kargo",
username: "",
password: "test",
}

err = s.validateCredentials(invalidCreds)

require.Error(t, err)

invalidCreds = specificCredentials{
project: "kargo-demo",
name: "test",
credType: "git",
repoURL: "https://github.com/akuity/kargo",
username: "test",
password: "",
}

err = s.validateCredentials(invalidCreds)

require.Error(t, err)

validCreds := specificCredentials{
project: "kargo-demo",
name: "test",
credType: "git",
repoURL: "https://github.com/akuity/kargo",
username: "test",
password: "test",
}

err = s.validateCredentials(validCreds)

require.NoError(t, err)
})

t.Run("invalid secret", func(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 2faf24f

Please sign in to comment.