Skip to content

Commit c5d72c9

Browse files
committed
fix similar bug for getting package info from registry when a different version is uploaded
1 parent 1051901 commit c5d72c9

File tree

2 files changed

+23
-1
lines changed
  • x-pack
    • plugins/fleet/server/services/epm/packages
    • test/fleet_api_integration/apis/epm

2 files changed

+23
-1
lines changed

x-pack/plugins/fleet/server/services/epm/packages/get.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ export async function getPackageInfo(options: {
9898
const getPackageRes = await getPackageFromSource({
9999
pkgName,
100100
pkgVersion,
101-
pkgInstallSource: savedObject?.attributes.install_source,
101+
pkgInstallSource:
102+
savedObject?.attributes.version === pkgVersion
103+
? savedObject?.attributes.install_source
104+
: 'registry',
102105
});
103106
const paths = getPackageRes.paths;
104107
const packageInfo = getPackageRes.packageInfo;

x-pack/test/fleet_api_integration/apis/epm/get.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,25 @@ export default function (providerContext: FtrProviderContext) {
7171
warnAndSkipTest(this, log);
7272
}
7373
});
74+
it('returns correct package info from registry if a different version is installed by upload', async function () {
75+
if (server.enabled) {
76+
const buf = fs.readFileSync(testPkgArchiveZip);
77+
await supertest
78+
.post(`/api/fleet/epm/packages`)
79+
.set('kbn-xsrf', 'xxxx')
80+
.type('application/zip')
81+
.send(buf)
82+
.expect(200);
83+
84+
const res = await supertest.get(`/api/fleet/epm/packages/apache-0.1.3`).expect(200);
85+
const packageInfo = res.body.response;
86+
expect(packageInfo.description).to.equal('Apache Integration');
87+
expect(packageInfo.download).to.not.equal(undefined);
88+
await uninstallPackage(testPkgKey);
89+
} else {
90+
warnAndSkipTest(this, log);
91+
}
92+
});
7493
it('returns a 500 for a package key without a proper name', async function () {
7594
if (server.enabled) {
7695
await supertest.get('/api/fleet/epm/packages/-0.1.0').expect(500);

0 commit comments

Comments
 (0)