Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed May 16, 2024
1 parent 9be3a5a commit 43cae89
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions api/types/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
package types

// OpenIDConfig is a struct that represents the OpenID Connect configuration.
//
// swagger:model OpenIDConfig
type OpenIDConfig struct {
Issuer string `json:"issuer"`
JWKSAddress string `json:"jwks_uri"`
Expand All @@ -11,6 +13,8 @@ type OpenIDConfig struct {
}

// JWKS is a slice of JWKs.
//
// swagger:model JWKS
type JWKS struct {
Keys []JWK `json:"keys"`
}
Expand Down
10 changes: 5 additions & 5 deletions database/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Resources struct {
Deployments []*library.Deployment
Executables []*library.BuildExecutable
Hooks []*library.Hook
JWKs []*api.JWK
JWKs []api.JWK
Logs []*library.Log
Pipelines []*library.Pipeline
Repos []*api.Repo
Expand Down Expand Up @@ -875,7 +875,7 @@ func testJWKs(t *testing.T, db Interface, resources *Resources) {
}

for _, jwk := range resources.JWKs {
err := db.CreateJWK(context.TODO(), *jwk)
err := db.CreateJWK(context.TODO(), jwk)
if err != nil {
t.Errorf("unable to create jwk %s: %v", jwk.Kid, err)
}
Expand Down Expand Up @@ -2555,7 +2555,7 @@ func newResources() *Resources {
hookThree.SetLink("https://github.com/github/octocat/settings/hooks/1")
hookThree.SetWebhookID(78910)

jwkOne := &api.JWK{
jwkOne := api.JWK{
Algorithm: "RS256",
Kid: "c8da1302-07d6-11ea-882f-4893bca275b8",
Kty: "rsa",
Expand All @@ -2564,7 +2564,7 @@ func newResources() *Resources {
E: "123",
}

jwkTwo := &api.JWK{
jwkTwo := api.JWK{
Algorithm: "RS256",
Kid: "c8da1302-07d6-11ea-882f-4893bca275b9",
Kty: "rsa",
Expand Down Expand Up @@ -2830,7 +2830,7 @@ func newResources() *Resources {
Deployments: []*library.Deployment{deploymentOne, deploymentTwo},
Executables: []*library.BuildExecutable{executableOne, executableTwo},
Hooks: []*library.Hook{hookOne, hookTwo, hookThree},
JWKs: []*api.JWK{jwkOne, jwkTwo},
JWKs: []api.JWK{jwkOne, jwkTwo},
Logs: []*library.Log{logServiceOne, logServiceTwo, logStepOne, logStepTwo},
Pipelines: []*library.Pipeline{pipelineOne, pipelineTwo},
Repos: []*api.Repo{repoOne, repoTwo},
Expand Down
3 changes: 3 additions & 0 deletions database/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/go-vela/server/database/deployment"
"github.com/go-vela/server/database/executable"
"github.com/go-vela/server/database/hook"
"github.com/go-vela/server/database/jwk"
"github.com/go-vela/server/database/log"
"github.com/go-vela/server/database/pipeline"
"github.com/go-vela/server/database/repo"
Expand Down Expand Up @@ -47,6 +48,8 @@ func TestDatabase_Engine_NewResources(t *testing.T) {
// ensure the mock expects the hook queries
_mock.ExpectExec(hook.CreatePostgresTable).WillReturnResult(sqlmock.NewResult(1, 1))
_mock.ExpectExec(hook.CreateRepoIDIndex).WillReturnResult(sqlmock.NewResult(1, 1))
// ensure the mock expects the jwk queries
_mock.ExpectExec(jwk.CreatePostgresTable).WillReturnResult(sqlmock.NewResult(1, 1))
// ensure the mock expects the log queries
_mock.ExpectExec(log.CreatePostgresTable).WillReturnResult(sqlmock.NewResult(1, 1))
_mock.ExpectExec(log.CreateBuildIDIndex).WillReturnResult(sqlmock.NewResult(1, 1))
Expand Down
4 changes: 2 additions & 2 deletions router/middleware/perm/perm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,8 @@ func TestPerm_MustIDRequestToken_WrongBuild(t *testing.T) {
// run test
engine.ServeHTTP(context.Writer, context.Request)

if resp.Code != http.StatusUnauthorized {
t.Errorf("MustBuildAccess returned %v, want %v", resp.Code, http.StatusOK)
if resp.Code != http.StatusBadRequest {
t.Errorf("MustBuildAccess returned %v, want %v", resp.Code, http.StatusBadRequest)
}
}

Expand Down

0 comments on commit 43cae89

Please sign in to comment.