Browse Source

Merge commit '76d15be087f910c1ed76e62398732d650eadcd39' into HEAD

feature/update-config-output-format-options
Jenkins 2 years ago
parent
commit
66d9852f2e
  1. 2
      auth/authorization.go
  2. 16
      auth/authorization_test.go
  3. 6
      main_test.go
  4. 3
      pipelines/executable_step.go
  5. 3
      pipelines/executable_step_test.go
  6. 5
      pipelines/pipeline.go
  7. 3
      pipelines/pipeline_test.go
  8. 3
      pipelines/step_test.go

2
auth/authorization.go

@ -23,6 +23,6 @@ func (middleware AuthenticationMiddleware) Middleware(next http.Handler) http.Ha
func CreateAuthenticationMiddleware(secret string) AuthenticationMiddleware {
return AuthenticationMiddleware{
secret: secret,
secret,
}
}

16
auth/authorization_test.go

@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestAuthorizationMiddleware(t *testing.T) {
func TestAuthenticationMiddleware(t *testing.T) {
token := faker.Word()
middleware := CreateAuthenticationMiddleware(token)
@ -19,7 +19,7 @@ func TestAuthorizationMiddleware(t *testing.T) {
middlewareHandler := middleware.Middleware(handler)
t.Run("AuthorizationMiddleware returns 403 response when authorization header is incorrect", func(t *testing.T) {
t.Run("AuthenticationMiddleware returns 403 response when authorization header is incorrect", func(t *testing.T) {
request, _ := http.NewRequest("GET", "/", nil)
responseRecorder := httptest.NewRecorder()
@ -28,7 +28,17 @@ func TestAuthorizationMiddleware(t *testing.T) {
assert.Equal(t, 403, responseRecorder.Code)
})
t.Run("AuthorizationMiddleware continues when authorization header is correct", func(t *testing.T) {
t.Run("AuthenticationMiddleware returns 403 response when authorization header is missing Bearer prefix", func(t *testing.T) {
request, _ := http.NewRequest("GET", "/", nil)
request.Header.Set("Authorization", token)
responseRecorder := httptest.NewRecorder()
middlewareHandler.ServeHTTP(responseRecorder, request)
assert.Equal(t, 403, responseRecorder.Code)
})
t.Run("AuthenticationMiddleware continues when authorization header is correct", func(t *testing.T) {
request, _ := http.NewRequest("GET", "/", nil)
request.Header.Set("Authorization", "Bearer "+token)
responseRecorder := httptest.NewRecorder()

6
main_test.go

@ -21,7 +21,7 @@ func TestIndexRoute(t *testing.T) {
IndexHandler(responseRecorder, request)
assert.Equal(t, responseRecorder.Code, 200, "Response code should be 200")
assert.Equal(t, 200, responseRecorder.Code, "Response code should be 200")
assert.NotNil(t, responseRecorder.Body, "Response should contain body")
})
}
@ -44,7 +44,7 @@ func TestEndpointRoute(t *testing.T) {
router.ServeHTTP(responseRecorder, request)
assert.Equal(t, responseRecorder.Code, 200)
assert.Equal(t, 200, responseRecorder.Code)
body, _ := json.Marshal(data)
assert.JSONEq(t, string(body), responseRecorder.Body.String())
})
@ -57,6 +57,6 @@ func TestEndpointRoute(t *testing.T) {
router.ServeHTTP(responseRecorder, request)
assert.Equal(t, responseRecorder.Code, 404)
assert.Equal(t, 404, responseRecorder.Code)
})
}

3
pipelines/executable_step.go

@ -3,8 +3,9 @@ package pipelines
import (
"errors"
"fmt"
"github.com/disintegration/imaging"
"image"
"github.com/disintegration/imaging"
)
type IExecutableStep interface {

3
pipelines/executable_step_test.go

@ -1,8 +1,9 @@
package pipelines
import (
"github.com/stretchr/testify/assert"
"testing"
"github.com/stretchr/testify/assert"
)
func TestDeserializeOptionsResizeImage(t *testing.T) {

5
pipelines/pipeline.go

@ -5,12 +5,13 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/disintegration/imaging"
"github.com/geplauder/lithium/storage"
"io/fs"
"log"
"os"
"path/filepath"
"github.com/disintegration/imaging"
"github.com/geplauder/lithium/storage"
)
// Pipelines

3
pipelines/pipeline_test.go

@ -1,12 +1,13 @@
package pipelines
import (
"github.com/geplauder/lithium/storage"
"image"
"os"
"path/filepath"
"testing"
"github.com/geplauder/lithium/storage"
"github.com/stretchr/testify/assert"
)

3
pipelines/step_test.go

@ -1,8 +1,9 @@
package pipelines
import (
"github.com/stretchr/testify/assert"
"testing"
"github.com/stretchr/testify/assert"
)
func TestTranslateStep(t *testing.T) {

Loading…
Cancel
Save