Skip to content

Versions API - Add `details` key to API

Zack Cuddy requested to merge 455_04-add-version-details-to-api into main

What / Why

The details key was added to the Versions record quite a bit ago: https://gitlab.com/gitlab-services/version-gitlab-com/-/merge_requests/689 but wasn't added to the Versions API. This change simply adds the field to the entity and valid params of the API.

Video Demo

Creating Versions Edit/Deleting Versions
Creating_Records Editing_Records

How to Test

Important: To test there is a bit of preliminary setup you will need to do. I visualize this in the video demo above

  1. Have a way to send POST requests with a JSON body. I used Postman w/ Postman Desktop Agent to fire localhost requests.
  2. A private_token to pass in the query of the request (this is likely not how we should do this in production, but works for verifying the API locally)
    • I used the Rails Console (rails c) and then this method User.first.private_token

Testing

  1. Follow all the important setup steps above
  2. Get your private token User.first.private_token
  3. Send a HTTP POST with the following information
    • path: localhost:3000/api/v1/versions
    • query_param: ?private_token=PRIVATE_TOKEN
    • body: { "version": "8.0.0", "security_release_type": "not_vulnerable", "details": "Testing" }
  4. Check UI and ensure version was created correctly
  5. Grab the ID of the version
  6. Send a HTTP PUT with the following information (note the different key vulnerability_type)
    • path: localhost:3000/api/v1/versions/ID
    • query_param: ?private_token=PRIVATE_TOKEN
    • body: { "vulnerability_type": "non_critical", "details": "Testing UPDATE" }
  7. Check UI and ensure version was updated correctly
  8. Send a HTTP DELETE with the following information
    • path: localhost:3000/api/v1/versions/ID
    • query_param: ?private_token=PRIVATE_TOKEN
  9. Ensure version is properly deleted

Merge request reports