Skip to content

Commit

Permalink
Change endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
kostas-kou committed Oct 15, 2024
1 parent 9242c96 commit cba4dff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sda/cmd/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func setup(config *config.Config) *http.Server {
r.POST("/file/accession", isAdmin(), setAccession) // assign accession ID to a file
r.POST("/dataset/create", isAdmin(), createDataset) // maps a set of files to a dataset
r.POST("/dataset/release/*dataset", isAdmin(), releaseDataset) // Releases a dataset to be accessible
r.POST("/key/hashed", isAdmin(), addHashedKey) // Adds a hashed key to the database
r.POST("/c4gh-keys/add", isAdmin(), addHashedKey) // Adds a key hash to the database
r.GET("/users", isAdmin(), listActiveUsers) // Lists all users
r.GET("/users/:username/files", isAdmin(), listUserFiles) // Lists all unmapped files for a user
}
Expand Down
2 changes: 1 addition & 1 deletion sda/cmd/api/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Admin endpoints are only available to a set of whitelisted users specified in th
- `401` Token user is not in the list of admins.
- `500` Internal error due to DB failure.

- `/key/hashed`
- `/c4gh-keys/add`
- accepts `POST` requests with the hex hash of the key and its description
- registers the key hash in the database.

Expand Down
8 changes: 4 additions & 4 deletions sda/cmd/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ func (suite *TestSuite) TestAddHashedKeySuccess() {
Conf.API.Admins = []string{"dummy"}

r := gin.Default()
r.POST("/key/hashed", isAdmin(), addHashedKey)
r.POST("/c4gh-keys/add", isAdmin(), addHashedKey)
ts := httptest.NewServer(r)
defer ts.Close()

Expand All @@ -1304,7 +1304,7 @@ func (suite *TestSuite) TestAddHashedKeySuccess() {
body, err := json.Marshal(keyhash)
assert.NoError(suite.T(), err)

req, err := http.NewRequest("POST", ts.URL+"/key/hashed", bytes.NewBuffer(body))
req, err := http.NewRequest("POST", ts.URL+"/c4gh-keys/add", bytes.NewBuffer(body))
assert.NoError(suite.T(), err)
req.Header.Add("Authorization", "Bearer "+suite.Token)
req.Header.Add("Content-Type", "application/json")
Expand All @@ -1321,7 +1321,7 @@ func (suite *TestSuite) TestAddHashedKeyInvalidJSON() {
Conf.API.Admins = []string{"dummy"}

r := gin.Default()
r.POST("/key/hashed", isAdmin(), addHashedKey)
r.POST("/c4gh-keys/add", isAdmin(), addHashedKey)
ts := httptest.NewServer(r)
defer ts.Close()

Expand All @@ -1331,7 +1331,7 @@ func (suite *TestSuite) TestAddHashedKeyInvalidJSON() {
// Create an invalid request body
body := []byte(`{"invalid_json"}`)

req, err := http.NewRequest("POST", ts.URL+"/key/hashed", bytes.NewBuffer(body))
req, err := http.NewRequest("POST", ts.URL+"/c4gh-keys/add", bytes.NewBuffer(body))
assert.NoError(suite.T(), err)
req.Header.Add("Authorization", "Bearer "+suite.Token)
req.Header.Add("Content-Type", "application/json")
Expand Down

0 comments on commit cba4dff

Please sign in to comment.