Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API endpoint for keys was accidentally changed #108

Closed
josecelano opened this issue Nov 4, 2022 · 0 comments · Fixed by #109
Closed

API endpoint for keys was accidentally changed #108

josecelano opened this issue Nov 4, 2022 · 0 comments · Fixed by #109
Assignees
Labels
Bug Incorrect Behavior

Comments

@josecelano
Copy link
Member

The tracker has an endpoint to generate new keys.

The response for that endpoint was like:

{
  "key": "IaWDneuFNZi8IB4MPA3qW1CD0M30EZSM",
  "valid_until": 1674804892
}

But now is like this:

{
  "key": "IaWDneuFNZi8IB4MPA3qW1CD0M30EZSM",
  "valid_until": 
    { 
      "secs": 1674804892, 
      "nanos": 423855037
    }
}

The change was introduced in this commit cab093c by @da2ce7.

The struct:

pub struct AuthKey {
    pub key: String,
    pub valid_until: Option<u64>,
 }

changed to:

pub struct AuthKey {
    pub key: String,
    pub valid_until: Option<DurationSinceUnixEpoch>,
}

Since we automatically build the json objects exposed in the API, that change was exposed to API consumers.

This change affected the [backend](More info: torrust/torrust-index#78).

@josecelano josecelano added the Bug Incorrect Behavior label Nov 4, 2022
josecelano added a commit that referenced this issue Nov 22, 2022
The response for the enpoint POST /api/key/:seconds_valid should be:

```json
{
  "key": "IaWDneuFNZi8IB4MPA3qW1CD0M30EZSM",
  "valid_until": 1674804892
}
```

instead of:

```json
{
  "key": "IaWDneuFNZi8IB4MPA3qW1CD0M30EZSM",
  "valid_until":
    {
      "secs": 1674804892,
      "nanos": 423855037
    }
}
```

It was propagated to the API after changing the internal struct `AuthKey` from:

```rust
pub struct AuthKey {
    pub key: String,
    pub valid_until: Option<u64>,
}
```

to:

```rust
pub struct AuthKey {
    pub key: String,
    pub valid_until: Option<DurationSinceUnixEpoch>,
}
```
josecelano added a commit that referenced this issue Nov 22, 2022
Added for API end to end tests.
josecelano added a commit that referenced this issue Nov 22, 2022
@josecelano josecelano self-assigned this Nov 22, 2022
josecelano added a commit that referenced this issue Nov 22, 2022
josecelano added a commit that referenced this issue Nov 23, 2022
It seems we need to wait a little bit until the server is ready to
accept requests.
@josecelano josecelano linked a pull request Nov 23, 2022 that will close this issue
2 tasks
josecelano added a commit that referenced this issue Nov 23, 2022
The response for the enpoint POST /api/key/:seconds_valid should be:

```json
{
  "key": "IaWDneuFNZi8IB4MPA3qW1CD0M30EZSM",
  "valid_until": 1674804892
}
```

instead of:

```json
{
  "key": "IaWDneuFNZi8IB4MPA3qW1CD0M30EZSM",
  "valid_until":
    {
      "secs": 1674804892,
      "nanos": 423855037
    }
}
```

It was propagated to the API after changing the internal struct `AuthKey` from:

```rust
pub struct AuthKey {
    pub key: String,
    pub valid_until: Option<u64>,
}
```

to:

```rust
pub struct AuthKey {
    pub key: String,
    pub valid_until: Option<DurationSinceUnixEpoch>,
}
```
josecelano added a commit that referenced this issue Nov 23, 2022
Added for API end to end tests.
da2ce7 added a commit to da2ce7/torrust-tracker that referenced this issue Nov 23, 2022
…n API endpoint

409f82a test: [torrust#108] add e2e test for auth key generation API endpoint (Jose Celano)
ede0460 feat: [torrust#108] add dev dependency reqwest (Jose Celano)
23916a6 fix: [torrust#108] revert change in auth key generation endpoint (Jose Celano)

Pull request description:

  Tasks:

  - [x] Revert change.
  - [x] E2E test for the endpoint.

ACKs for top commit:
  da2ce7:
    ACK 409f82a

Tree-SHA512: 66422f2ab68925581fde950b1d618899189160df1d0d07c747f833d909d44fe2f945d212362cd8454f1f9c384f67b1c4dffdde66ec5e175a1cd12114977e630d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Incorrect Behavior
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant