Skip to content

Commit

Permalink
Merge pull request #832 from iotaledger/fix/committee-api
Browse files Browse the repository at this point in the history
Fix wrong public route of committee endpoint in core API
  • Loading branch information
muXxer authored Mar 13, 2024
2 parents b0a260d + c0a9e6b commit eb20122
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion components/restapi/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var ParamsRestAPI = &ParametersRestAPI{
"/api/core/v3/accounts*",
"/api/core/v3/validators*",
"/api/core/v3/rewards*",
"/api/core/v3/committee",
"/api/core/v3/committee*",
"/api/debug/v2/*",
"/api/indexer/v2/*",
"/api/mqtt/v2",
Expand Down
2 changes: 1 addition & 1 deletion config_defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"/api/core/v3/accounts*",
"/api/core/v3/validators*",
"/api/core/v3/rewards*",
"/api/core/v3/committee",
"/api/core/v3/committee*",
"/api/debug/v2/*",
"/api/indexer/v2/*",
"/api/mqtt/v2",
Expand Down
24 changes: 12 additions & 12 deletions documentation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,17 @@ Example:

## <a id="restapi"></a> 5. RestAPI

| Name | Description | Type | Default value |
| ------------------------------ | ---------------------------------------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| bindAddress | The bind address on which the REST API listens on | string | "0.0.0.0:14265" |
| publicRoutes | The HTTP REST routes which can be called without authorization. Wildcards using \* are allowed | array | /health<br/>/api/routes<br/>/api/core/v3/info<br/>/api/core/v3/network\*<br/>/api/core/v3/blocks\*<br/>/api/core/v3/transactions\*<br/>/api/core/v3/commitments\*<br/>/api/core/v3/outputs\*<br/>/api/core/v3/accounts\*<br/>/api/core/v3/validators\*<br/>/api/core/v3/rewards\*<br/>/api/core/v3/committee<br/>/api/debug/v2/\*<br/>/api/indexer/v2/\*<br/>/api/mqtt/v2<br/>/api/blockissuer/v1/\* |
| protectedRoutes | The HTTP REST routes which need to be called with authorization. Wildcards using \* are allowed | array | /api/\* |
| debugRequestLoggerEnabled | Whether the debug logging for requests should be enabled | boolean | false |
| maxPageSize | The maximum number of results per page | uint | 100 |
| requestsMemoryCacheGranularity | Defines per how many slots a cache is created for big API requests | uint | 10 |
| maxRequestedSlotAge | The maximum age of a request that will be processed | uint | 10 |
| [jwtAuth](#restapi_jwtauth) | Configuration for jwtAuth | object | |
| [limits](#restapi_limits) | Configuration for limits | object | |
| Name | Description | Type | Default value |
| ------------------------------ | ---------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| bindAddress | The bind address on which the REST API listens on | string | "0.0.0.0:14265" |
| publicRoutes | The HTTP REST routes which can be called without authorization. Wildcards using \* are allowed | array | /health<br/>/api/routes<br/>/api/core/v3/info<br/>/api/core/v3/network\*<br/>/api/core/v3/blocks\*<br/>/api/core/v3/transactions\*<br/>/api/core/v3/commitments\*<br/>/api/core/v3/outputs\*<br/>/api/core/v3/accounts\*<br/>/api/core/v3/validators\*<br/>/api/core/v3/rewards\*<br/>/api/core/v3/committee\*<br/>/api/debug/v2/\*<br/>/api/indexer/v2/\*<br/>/api/mqtt/v2<br/>/api/blockissuer/v1/\* |
| protectedRoutes | The HTTP REST routes which need to be called with authorization. Wildcards using \* are allowed | array | /api/\* |
| debugRequestLoggerEnabled | Whether the debug logging for requests should be enabled | boolean | false |
| maxPageSize | The maximum number of results per page | uint | 100 |
| requestsMemoryCacheGranularity | Defines per how many slots a cache is created for big API requests | uint | 10 |
| maxRequestedSlotAge | The maximum age of a request that will be processed | uint | 10 |
| [jwtAuth](#restapi_jwtauth) | Configuration for jwtAuth | object | |
| [limits](#restapi_limits) | Configuration for limits | object | |

### <a id="restapi_jwtauth"></a> JwtAuth

Expand Down Expand Up @@ -209,7 +209,7 @@ Example:
"/api/core/v3/accounts*",
"/api/core/v3/validators*",
"/api/core/v3/rewards*",
"/api/core/v3/committee",
"/api/core/v3/committee*",
"/api/debug/v2/*",
"/api/indexer/v2/*",
"/api/mqtt/v2",
Expand Down
18 changes: 18 additions & 0 deletions tools/docker-network/tests/coreapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,15 @@ func Test_CoreAPI(t *testing.T) {
require.EqualValues(t, 4, len(resp.Committee))
},
},
{
name: "Test_CommitteeWithEpoch",
testFunc: func(t *testing.T, nodeAlias string) {
resp, err := d.wallet.Clients[nodeAlias].Committee(context.Background(), 0)
require.NoError(t, err)
require.Equal(t, iotago.EpochIndex(0), resp.Epoch)
require.Equal(t, 4, len(resp.Committee))
},
},
}

for _, test := range tests {
Expand Down Expand Up @@ -534,6 +543,15 @@ func Test_CoreAPI_BadRequests(t *testing.T) {
require.Nil(t, resp)
},
},
{
name: "Test_Committee_Failure",
testFunc: func(t *testing.T, nodeAlias string) {
resp, err := d.wallet.Clients[nodeAlias].Committee(context.Background(), 4)
require.Error(t, err)
require.True(t, isStatusCode(err, http.StatusBadRequest))
require.Nil(t, resp)
},
},
{
name: "Test_Rewards_Failure",
testFunc: func(t *testing.T, nodeAlias string) {
Expand Down

0 comments on commit eb20122

Please sign in to comment.