Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Nov 11, 2024
1 parent efa2a88 commit 9c702bf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export default ({ getService }: FtrProviderContext) => {
responseBody: {
statusCode: 403,
error: 'Forbidden',
message: 'Forbidden',
},
},
},
Expand Down Expand Up @@ -133,7 +132,6 @@ export default ({ getService }: FtrProviderContext) => {
);
} else {
expect(body.error).to.eql(testData.expected.responseBody.error);
expect(body.message).to.eql(testData.expected.responseBody.message);
}
});
}
Expand Down
2 changes: 0 additions & 2 deletions x-pack/test/api_integration/apis/ml/filters/create_filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export default ({ getService }: FtrProviderContext) => {
responseCode: 403,
responseBody: {
error: 'Forbidden',
message: 'Forbidden',
},
},
},
Expand All @@ -58,7 +57,6 @@ export default ({ getService }: FtrProviderContext) => {
responseCode: 403,
responseBody: {
error: 'Forbidden',
message: 'Forbidden',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,6 @@ export default ({ getService }: FtrProviderContext) => {
expected: {
responseCode: 403,
error: 'Forbidden',
message: 'Forbidden',
},
},
];
Expand Down
26 changes: 16 additions & 10 deletions x-pack/test/api_integration/apis/ml/system/has_privileges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import expect from '@kbn/expect';

import { MlHasPrivilegesResponse } from '@kbn/ml-plugin/public/application/services/ml_api_service';
import { FtrProviderContext } from '../../../ftr_provider_context';
import { getCommonRequestHeader } from '../../../../functional/services/ml/common_api';
import { USER } from '../../../../functional/services/ml/security_common';
Expand All @@ -17,11 +16,7 @@ export default ({ getService }: FtrProviderContext) => {
const supertest = getService('supertestWithoutAuth');
const ml = getService('ml');

async function runRequest(
user: USER,
index: any,
expectedStatusCode = 200
): Promise<MlHasPrivilegesResponse> {
async function runRequest(user: USER, index: any, expectedStatusCode = 200) {
const { body, status } = await supertest
.post(`/internal/ml/_has_privileges`)
.auth(user, ml.securityCommon.getPasswordForUser(user))
Expand Down Expand Up @@ -104,7 +99,10 @@ export default ({ getService }: FtrProviderContext) => {
privileges: ['write'],
},
],
expectedResponse: { statusCode: 403, error: 'Forbidden', message: 'Forbidden' },
expectedResponse: {
statusCode: 403,
error: 'Forbidden',
},
expectedStatusCode: 403,
},
];
Expand All @@ -120,9 +118,17 @@ export default ({ getService }: FtrProviderContext) => {
it('should return correct privileges for test data', async () => {
for (const { user, index, expectedResponse, expectedStatusCode } of testData) {
const response = await runRequest(user, index, expectedStatusCode);
expect(response).to.eql(
expectedResponse,
`expected ${JSON.stringify(expectedResponse)}, got ${JSON.stringify(response)}`
expect(response.statusCode).to.eql(
expectedResponse.statusCode,
`expected ${JSON.stringify(expectedResponse.statusCode)}, got ${JSON.stringify(
response.statusCode
)}`
);
expect(response.error).to.eql(
expectedResponse.error,
`expected ${JSON.stringify(expectedResponse.error)}, got ${JSON.stringify(
response.error
)}`
);
}
});
Expand Down

0 comments on commit 9c702bf

Please sign in to comment.