Skip to content

Commit

Permalink
feat: Set reverse proxy response content-type to application/json (#106)
Browse files Browse the repository at this point in the history
* feat: Add get test

Signed-off-by: Ce Gao <[email protected]>

* fix: Fix

Signed-off-by: Ce Gao <[email protected]>
  • Loading branch information
Ce Gao authored Sep 7, 2020
1 parent b59bb7d commit e9ff8ce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ cover.out
config.json

.DS_Store
cache/
2 changes: 2 additions & 0 deletions pkg/registry/harbor/harbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func (p Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
resp.Header["Location"] = []string{strings.ReplaceAll(location[0], p.Domain,
viper.GetString(envModelRestirtyExternalAddress))}
}
// It is to solve https://github.com/kleveross/klever-model-registry/issues/104
resp.Header.Set("content-type", "application/json")
return nil
}

Expand Down
22 changes: 16 additions & 6 deletions testutil/integration/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package integration

import (
"encoding/json"
"net/http"

httpexpect "github.com/gavv/httpexpect/v2"
"github.com/kleveross/klever-model-registry/pkg/registry/models"
Expand All @@ -14,20 +15,21 @@ var _ = Describe("Model Registry", func() {
Context("ModelJobs", func() {
It("Should get the ModelJobs successfully", func() {
e.GET("/api/v1alpha1/namespaces/{namespace}/modeljobs/",
"default").Expect().Status(200)
"default").Expect().Status(http.StatusOK)
})
})
Context("Servings", func() {
It("Should get the Servings successfully", func() {
e.GET("/api/v1alpha1/namespaces/{namespace}/servings/",
"default").Expect().Status(200)
"default").Expect().Status(http.StatusOK)
})
})
Context("Models", func() {
project := "library"
model := "tensorflow"
version := "test"

It("Should push the model successfully", func() {
project := "library"
model := "tensorflow"
version := "test"
modelContent := models.Model{
ProjectName: project,
ModelName: model,
Expand All @@ -45,7 +47,15 @@ var _ = Describe("Model Registry", func() {
}).
WithMultipart().
WithFile("file", "./models/model.zip").WithFormField("model", string(bytes)).
Expect().Status(201)
Expect().Status(http.StatusCreated)
})
It("Should list the model successfully", func() {
artifact := e.GET("/api/v2.0/projects/{project_name}/repositories/{repository_name}/artifacts/{version}",
project, model, version).Expect().Status(http.StatusOK).JSON().Object()
// Validate that the artifact is a SavedModel.
// It is blocked since goharbor/harbor-helm does not support 2.1 now.
// artifact.Value("extra_attrs").Object().Value("format").Equal("SavedModel")
artifact.Value("type").Equal("MODEL")
})
})
})

0 comments on commit e9ff8ce

Please sign in to comment.