ShahriyarR / one-time-secret-share

One time secret sharing service on top of ReadOnce objects
MIT License
21 stars 5 forks source link

Add Public API support for creating and getting secrets #44

Open ShahriyarR opened 1 year ago

ShahriyarR commented 1 year ago

What would you like to be added?

Use DRF - https://www.django-rest-framework.org/

The public APIs:

/api/v1/secret - POST for creating the secret, returns the UUID
/api/v1/secret/UUID - GET get the secret returns the secret

Concerns:

All other ReadOnce object requirements should remain the same.

Why is this needed?

In some applications and organizations, it can be required to create secrets using the API interface to automate the process.

ShahriyarR commented 1 year ago

For more clarification about endpoint requirements, I am going to add few BDD scenarios:


Feature: Create a secret with POST request to /api/v1/secret

  Scenario: Create a secret with a valid secret string
    Given a valid secret string "mySecret"
    When a POST request is sent to "/api/v1/secret" with the secret string
    Then a unique UUID URL is generated

  Scenario: Create a secret with an empty secret string
    Given an empty secret string
    When a POST request is sent to "/api/v1/secret" with the secret string
    Then the API returns an error response with status code 400
    And the response body contains an error message indicating the invalid secret string

To retrieve secret:

Feature: Retrieve a secret using the /api/v1/secret/UUID endpoint

  Scenario: Retrieve a secret using a valid UUID URL via GET request
    Given a valid UUID URL "123e4567-e89b-12d3-a456-426614174000"
    When a GET request is sent to "/api/v1/secret/123e4567-e89b-12d3-a456-426614174000"
    Then the API returns the corresponding secret
    And the response contains the secret string

  Scenario: Retrieve a secret using an invalid UUID URL via GET request
    Given an invalid UUID URL "invalid-uuid"
    When a GET request is sent to "/api/v1/secret/invalid-uuid"
    Then the API returns an error response with status code 404
    And the response body contains an error message indicating the invalid UUID URL