-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix(6023): replace list with items * fix(6023): added changelog * fix(6023): added test validating the new items matches the deprecated list * fix(6023): added comment to better trace where the integration test comes from The integration test added in this pull request needs to be removed once the list component is removed from the kibana api * fixs(6023): ran mage update * fix(6023): add build tag to integration test * fix(6023): added unit test for kibanaFetchToken * fix(6023): added error checks in unit test (cherry picked from commit 68d5833) Co-authored-by: Kaan Yalti <[email protected]>
- Loading branch information
1 parent
a9f8cf5
commit 1f89c72
Showing
4 changed files
with
171 additions
and
7 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
changelog/fragments/1735137195-remove-deprecated-list-in-favor-of-items.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Kind can be one of: | ||
# - breaking-change: a change to previously-documented behavior | ||
# - deprecation: functionality that is being removed in a later release | ||
# - bug-fix: fixes a problem in a previous version | ||
# - enhancement: extends functionality but does not break or fix existing behavior | ||
# - feature: new functionality | ||
# - known-issue: problems that we are aware of in a given version | ||
# - security: impacts on the security of a product or a user’s deployment. | ||
# - upgrade: important information for someone upgrading from a prior version | ||
# - other: does not fit into any of the other categories | ||
kind: feature | ||
|
||
# Change summary; a 80ish characters long description of the change. | ||
summary: removes `list` from kibanaFetchToken in favor of `items` as the former is deprecated and will be removed from the api response | ||
|
||
# Long description; in case the summary is not enough to describe the change | ||
# this field accommodate a description without length limits. | ||
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment. | ||
#description: | ||
|
||
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc. | ||
component: "elastic-agent" | ||
|
||
# PR URL; optional; the PR number that added the changeset. | ||
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added. | ||
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number. | ||
# Please provide it if you are adding a fragment for a different PR. | ||
pr: https://github.com/elastic/elastic-agent/pull/6437 | ||
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of). | ||
# If not present is automatically filled by the tooling with the issue linked to the PR number. | ||
issue: https://github.com/elastic/elastic-agent/issues/6023 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
testing/integration/validate_items_deprecated_list_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License 2.0; | ||
// you may not use this file except in compliance with the Elastic License 2.0. | ||
|
||
//go:build integration | ||
|
||
package integration | ||
|
||
import ( | ||
"encoding/json" | ||
"io" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/elastic/elastic-agent/pkg/testing/define" | ||
) | ||
|
||
type testKibanaApiKey struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
Active bool `json:"active"` | ||
PolicyID string `json:"policy_id"` | ||
APIKey string `json:"api_key"` | ||
} | ||
|
||
type deprecatedBody struct { | ||
List []testKibanaApiKey `json:"list"` | ||
} | ||
|
||
type newBody struct { | ||
Items []testKibanaApiKey `json:"items"` | ||
} | ||
|
||
// TODO: Remove test after list deprecation is complete | ||
// Added by https://github.com/elastic/elastic-agent/pull/6437 | ||
func TestItemsMatchDeprecatedList(t *testing.T) { | ||
info := define.Require(t, define.Requirements{ | ||
Group: Default, | ||
Stack: &define.Stack{}, | ||
Local: true, | ||
Sudo: false, | ||
}) | ||
|
||
res, err := info.KibanaClient.Connection.Send(http.MethodGet, "/api/fleet/enrollment_api_keys", nil, nil, nil) | ||
require.NoError(t, err) | ||
defer res.Body.Close() | ||
|
||
body, err := io.ReadAll(res.Body) | ||
require.NoError(t, err) | ||
|
||
dpb := deprecatedBody{} | ||
nb := newBody{} | ||
|
||
err = json.Unmarshal(body, &dpb) | ||
require.NoError(t, err) | ||
|
||
err = json.Unmarshal(body, &nb) | ||
require.NoError(t, err) | ||
|
||
require.Equal(t, len(dpb.List), len(nb.Items)) | ||
for i := 0; i < len(dpb.List); i++ { | ||
require.Equal(t, dpb.List[i], nb.Items[i]) | ||
} | ||
} |