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 14, 2024
1 parent f42102a commit cde3d09
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions pkg/idp/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,45 @@ 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.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 +204,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 cde3d09

Please sign in to comment.