Skip to content

Commit

Permalink
[Fleet] Fix bug caused by API changes (#120886)
Browse files Browse the repository at this point in the history
* fix endpoint integration

* added test
  • Loading branch information
juliaElastic committed Dec 9, 2021
1 parent 0457cd1 commit 3a7d24b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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);
});
});
}

0 comments on commit 3a7d24b

Please sign in to comment.