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

[8.0] [Fleet] Fix bug caused by API changes (#120886) #120919

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion x-pack/plugins/fleet/server/routes/epm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ export const registerRoutes = (routers: { rbac: FleetRouter; superuser: FleetRou
response
);
if (resp.payload?.item) {
return response.ok({ body: { response: resp.payload.item } });
// returning item as well here, because pkgVersion is optional in new GET endpoint, and if not specified, the router selects the deprecated route
return response.ok({ body: { item: resp.payload.item, response: resp.payload.item } });
}
return resp;
}
Expand Down
10 changes: 10 additions & 0 deletions x-pack/test/fleet_api_integration/apis/epm/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,15 @@ export default function (providerContext: FtrProviderContext) {
.auth(testUsers.fleet_read_only.username, testUsers.fleet_read_only.password)
.expect(200);
});

it('returns package info in item field when calling without version', async function () {
// this will install through the registry by default
await installPackage(testPkgName, testPkgVersion);
const res = await supertest.get(`/api/fleet/epm/packages/${testPkgName}`).expect(200);
const packageInfo = res.body.item;
// the uploaded version will have this description
expect(packageInfo.name).to.equal('apache');
await uninstallPackage(testPkgName, testPkgVersion);
});
});
}