diff --git a/.dredd/hooks/main.go b/.dredd/hooks/main.go index f561af0b..361864ac 100644 --- a/.dredd/hooks/main.go +++ b/.dredd/hooks/main.go @@ -93,6 +93,7 @@ func main() { h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/matchers > Add Integration Matcher > 204 > application/json", capabilityWrapper("integration")) h.Before("integration > /api/project/{project_id}/integrations/{integration_id}/matchers/{matcher_id} > Updates Integration Matcher > 204 > application/json", capabilityWrapper("integrationmatcher")) + h.Before("project > /api/project/{project_id}/keys > Add access key > 201 > application/json", capabilityWrapper("access_key")) h.Before("project > /api/project/{project_id}/keys/{key_id} > Updates access key > 204 > application/json", capabilityWrapper("access_key")) h.Before("project > /api/project/{project_id}/keys/{key_id} > Removes access key > 204 > application/json", capabilityWrapper("access_key")) diff --git a/api-docs.yml b/api-docs.yml index 9461187d..e10e238d 100644 --- a/api-docs.yml +++ b/api-docs.yml @@ -368,6 +368,8 @@ definitions: type: integer minimum: 1 x-example: 2 + override_secret: + type: boolean login_password: type: object properties: @@ -386,6 +388,10 @@ definitions: type: string x-example: user example: user + passphrase: + type: string + x-example: passphrase + example: passphrase private_key: type: string x-example: private key @@ -1741,8 +1747,10 @@ paths: schema: $ref: "#/definitions/AccessKeyRequest" responses: - 204: + 201: description: Access Key created + schema: + $ref: "#/definitions/AccessKey" 400: description: Bad type /project/{project_id}/keys/{key_id}: diff --git a/api/projects/keys.go b/api/projects/keys.go index c3922454..02e9c31d 100644 --- a/api/projects/keys.go +++ b/api/projects/keys.go @@ -101,7 +101,14 @@ func AddKey(w http.ResponseWriter, r *http.Request) { Description: fmt.Sprintf("Access Key %s created", key.Name), }) - w.WriteHeader(http.StatusNoContent) + // Reload key to drop sensitive fields + key, err = helpers.Store(r).GetAccessKey(*newKey.ProjectID, newKey.ID) + if err != nil { + helpers.WriteError(w, err) + return + } + + helpers.WriteJSON(w, http.StatusCreated, key) } // UpdateKey updates key in database