Skip to content

Commit

Permalink
test: add tests for changed spec
Browse files Browse the repository at this point in the history
  • Loading branch information
BarcoMasile committed Nov 13, 2024
1 parent f065f42 commit 01fa6d9
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions pkg/idp/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,46 @@ func TestValidate(t *testing.T) {
expectedResult: nil,
expectedError: nil,
},
{
name: "CreateIdPSuccessWithOIDCDiscovery",
method: http.MethodPost,
endpoint: "",
body: func() []byte {
conf := new(Configuration)
conf.ID = "google_generic"
conf.Provider = "generic"
conf.IssuerURL = "mock-url"
conf.SubjectSource = "me"
conf.Scope = []string{}
conf.Mapper = "mock-url"

marshal, _ := json.Marshal(conf)
return marshal
},
expectedResult: nil,
expectedError: nil,
},
{
name: "CreateIdPSuccessWithoutOIDCDiscovery",
method: http.MethodPost,
endpoint: "",
body: func() []byte {
conf := new(Configuration)
conf.ID = "google_generic"
conf.Provider = "generic"
conf.IssuerURL = "mock-url"
conf.AuthURL = "mock-url"
conf.TokenURL = "mock-url"
conf.SubjectSource = "me"
conf.Scope = []string{}
conf.Mapper = "mock-url"

marshal, _ := json.Marshal(conf)
return marshal
},
expectedResult: nil,
expectedError: nil,
},
{
name: "PartialUpdateIdPSuccess",
method: http.MethodPatch,
Expand Down Expand Up @@ -165,6 +205,23 @@ func TestValidate(t *testing.T) {
expectedResult: validator.ValidationErrors{},
expectedError: nil,
},
{
name: "CreateIdPEmptyURLsAndIssuerValidationError",
method: http.MethodPost,
endpoint: "",
body: func() []byte {
conf := new(Configuration)
conf.Provider = "generic"
conf.SubjectSource = "me"
conf.Scope = []string{"profile"}
conf.Mapper = "mock-url"

marshal, _ := json.Marshal(conf)
return marshal
},
expectedResult: validator.ValidationErrors{},
expectedError: nil,
},
{
name: "PartialUpdateIdPValidationError",
method: http.MethodPatch,
Expand Down

0 comments on commit 01fa6d9

Please sign in to comment.