github.com/kyma-project/kyma-environment-broker@v0.0.1/testing/e2e/skr/skr-networking-test/index.js (about) 1 const { 2 gatherOptions, 3 } = require('../skr-test'); 4 const {getOrProvisionSKR} = require('../skr-test/provision/provision-skr'); 5 const {deprovisionAndUnregisterSKR} = require('../skr-test/provision/deprovision-skr'); 6 const {withCustomParams} = require('../skr-test'); 7 const {expect} = require('chai'); 8 const {KEBClient, KEBConfig} = require('../kyma-environment-broker'); 9 const axios = require('axios'); 10 const keb = new KEBClient(KEBConfig.fromEnv()); 11 12 const skipProvisioning = process.env.SKIP_PROVISIONING === 'true'; 13 const provisioningTimeout = 1000 * 60 * 30; // 30m 14 const deprovisioningTimeout = 1000 * 60 * 95; // 95m 15 let globalTimeout = 1000 * 60 * 30; // 20m 16 const slowTime = 5000; 17 18 describe('SKR AWS networking test', function() { 19 if (!skipProvisioning) { 20 globalTimeout += provisioningTimeout + deprovisioningTimeout; 21 } 22 this.timeout(globalTimeout); 23 this.slow(slowTime); 24 25 let skr; 26 27 const customParams = { 28 'networking': {'nodes': '10.253.0.0/21'}, 29 }; 30 let options = gatherOptions( 31 withCustomParams(customParams), 32 ); 33 console.log('Using custom parameters: %o', customParams); 34 35 it('Try networking params which overlap with restricted IP range', async function() { 36 const customParams = {'networking': {'nodes': '10.242.0.0/22'}}; 37 const payload = keb.buildPayload('wrong-nodes', 'id01234876', null, null, customParams); 38 const endpoint = `service_instances/id01234876`; 39 const config = await keb.buildRequest(payload, endpoint, 'put'); 40 41 try { 42 await axios.request(config); 43 fail('KEB must return an error'); 44 } catch (err) { 45 expect(err.response.status).equal(400); 46 expect(err.response.data.description).to.include('overlap'); 47 console.log('Got response:'); 48 console.log(err.response.data); 49 } 50 }); 51 it('Try networking params with invalid IP range', async function() { 52 const customParams = {'networking': {'nodes': '333.242.0.0/22'}}; 53 const payload = keb.buildPayload('wrong-nodes', 'id01234873', null, null, customParams); 54 const endpoint = `service_instances/id01234876`; 55 const config = await keb.buildRequest(payload, endpoint, 'put'); 56 57 try { 58 await axios.request(config); 59 fail('KEB must return an error'); 60 } catch (err) { 61 console.log('Got response:'); 62 console.log(err.response.data); 63 expect(err.response.status).equal(400); 64 } 65 }); 66 it('Perform provisioning', async function() { 67 this.timeout(provisioningTimeout); 68 skr = await getOrProvisionSKR(options, skipProvisioning, provisioningTimeout); 69 options = skr.options; 70 }); 71 72 after('Clean up the resources', async function() { 73 this.timeout(deprovisioningTimeout); 74 await deprovisionAndUnregisterSKR(options, deprovisioningTimeout, skipProvisioning, false); 75 }); 76 });