Skip to content

Commit

Permalink
adjust api integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dominiqueclarke committed Jan 23, 2023
1 parent d1c3adf commit 455c821
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1472,69 +1472,7 @@ export default function ({ getService }: FtrProviderContext) {
type: 'http',
tags: 'tag2,tag2',
urls: ['http://localhost:9200'],
},
reason: 'Cannot update monitor to different type.',
},
],
});
} finally {
await Promise.all([
projectMonitors.monitors.map((monitor) => {
return deleteMonitor(monitor.id, project);
}),
]);
}
});

it('project monitors - cannot update a monitor of one type to another type', async () => {
const project = `test-project-${uuidv4()}`;

try {
await supertest
.put(API_URLS.SYNTHETICS_MONITORS_PROJECT_UPDATE.replace('{projectName}', project))
.set('kbn-xsrf', 'true')
.send(projectMonitors)
.expect(200);
const { body } = await supertest
.put(API_URLS.SYNTHETICS_MONITORS_PROJECT_UPDATE.replace('{projectName}', project))
.set('kbn-xsrf', 'true')
.send({
monitors: [{ ...httpProjectMonitors.monitors[1], id: projectMonitors.monitors[0].id }],
})
.expect(200);
expect(body).eql({
createdMonitors: [],
updatedMonitors: [],
failedMonitors: [
{
details: `Monitor ${projectMonitors.monitors[0].id} of type browser cannot be updated to type http. Please delete the monitor first and try again.`,
payload: {
'check.request': {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
method: 'POST',
},
'check.response': {
body: {
positive: ['Saved', 'saved'],
},
status: [200],
},
enabled: false,
hash: 'ekrjelkjrelkjre',
id: projectMonitors.monitors[0].id,
locations: ['localhost'],
name: 'My Monitor 3',
response: {
include_body: 'always',
},
'response.include_headers': false,
schedule: 60,
timeout: '80s',
type: 'http',
tags: 'tag2,tag2',
urls: ['http://localhost:9200'],
'ssl.verification_mode': 'strict',
},
reason: 'Cannot update monitor to different type.',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export default function ({ getService }: FtrProviderContext) {

for (const monitor of successfulMonitors) {
const journeyId = monitor.id;
const isTLSEnabled = Object.keys(monitor).some((key) => key.includes('ssl'));
const createdMonitorsResponse = await supertest
.get(API_URLS.SYNTHETICS_MONITORS)
.query({ filter: `${syntheticsMonitorType}.attributes.journey_id: ${journeyId}` })
Expand All @@ -253,7 +254,7 @@ export default function ({ getService }: FtrProviderContext) {

expect(decryptedCreatedMonitor.body.attributes).to.eql({
__ui: {
is_tls_enabled: false,
is_tls_enabled: isTLSEnabled,
},
'check.request.method': 'POST',
'check.response.status': ['200'],
Expand Down Expand Up @@ -308,7 +309,7 @@ export default function ({ getService }: FtrProviderContext) {
'ssl.certificate': '',
'ssl.certificate_authorities': '',
'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'],
'ssl.verification_mode': 'full',
'ssl.verification_mode': isTLSEnabled ? 'strict' : 'full',
'ssl.key': '',
'ssl.key_passphrase': '',
tags: Array.isArray(monitor.tags) ? monitor.tags : monitor.tags?.split(','),
Expand Down Expand Up @@ -357,6 +358,7 @@ export default function ({ getService }: FtrProviderContext) {

for (const monitor of successfulMonitors) {
const journeyId = monitor.id;
const isTLSEnabled = Object.keys(monitor).some((key) => key.includes('ssl'));
const createdMonitorsResponse = await supertest
.get(API_URLS.SYNTHETICS_MONITORS)
.query({ filter: `${syntheticsMonitorType}.attributes.journey_id: ${journeyId}` })
Expand All @@ -370,7 +372,7 @@ export default function ({ getService }: FtrProviderContext) {

expect(decryptedCreatedMonitor.body.attributes).to.eql({
__ui: {
is_tls_enabled: false,
is_tls_enabled: isTLSEnabled,
},
config_id: decryptedCreatedMonitor.body.id,
custom_heartbeat_id: `${journeyId}-test-suite-default`,
Expand Down Expand Up @@ -411,7 +413,7 @@ export default function ({ getService }: FtrProviderContext) {
'ssl.certificate': '',
'ssl.certificate_authorities': '',
'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'],
'ssl.verification_mode': 'full',
'ssl.verification_mode': isTLSEnabled ? 'strict' : 'full',
'ssl.key': '',
'ssl.key_passphrase': '',
tags: Array.isArray(monitor.tags) ? monitor.tags : monitor.tags?.split(','),
Expand Down Expand Up @@ -1783,7 +1785,7 @@ export default function ({ getService }: FtrProviderContext) {
dataset: 'http',
},
vars: {
__ui: { value: '{"is_tls_enabled":false}', type: 'yaml' },
__ui: { value: '{"is_tls_enabled":true}', type: 'yaml' },
enabled: { value: false, type: 'bool' },
type: { value: 'http', type: 'text' },
name: { value: 'My Monitor 3', type: 'text' },
Expand Down Expand Up @@ -1812,7 +1814,7 @@ export default function ({ getService }: FtrProviderContext) {
'ssl.certificate': { value: null, type: 'yaml' },
'ssl.key': { value: null, type: 'yaml' },
'ssl.key_passphrase': { value: null, type: 'text' },
'ssl.verification_mode': { value: 'full', type: 'text' },
'ssl.verification_mode': { value: 'strict', type: 'text' },
'ssl.supported_protocols': {
value: '["TLSv1.1","TLSv1.2","TLSv1.3"]',
type: 'yaml',
Expand All @@ -1836,7 +1838,7 @@ export default function ({ getService }: FtrProviderContext) {
},
id: `synthetics/http-http-${id}-${testPolicyId}`,
compiled_stream: {
__ui: { is_tls_enabled: false },
__ui: { is_tls_enabled: true },
type: 'http',
name: 'My Monitor 3',
id,
Expand All @@ -1853,7 +1855,7 @@ export default function ({ getService }: FtrProviderContext) {
'check.request.headers': { 'Content-Type': 'application/x-www-form-urlencoded' },
'check.response.status': ['200'],
'check.response.body.positive': ['Saved', 'saved'],
'ssl.verification_mode': 'full',
'ssl.verification_mode': 'strict',
'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'],
'run_from.geo.name': 'Test private location 0',
'run_from.id': 'Test private location 0',
Expand Down

0 comments on commit 455c821

Please sign in to comment.