github.com/kyma-project/kyma-environment-broker@v0.0.1/testing/e2e/skr/keb-endpoints-test/index.js (about)

     1  const {
     2    KEBClient,
     3    KEBConfig,
     4  } = require('../kyma-environment-broker');
     5  
     6  const keb = new KEBClient(KEBConfig.fromEnv());
     7  async function testEndpointWithoutToken(requestBody, endpoint, method) {
     8    try {
     9      await keb.callKEBWithoutToken(requestBody, endpoint, method);
    10    } catch (err) {
    11      throw new Error(`error while calling KEB endpoint "${endpoint}" without authorization: ${err.toString()}`);
    12    }
    13  }
    14  
    15  describe('KEB endpoints test', function() {
    16    const instanceID = 'keb-endpoints-test';
    17    const platformRegion = keb.getPlatformRegion();
    18    const testData = [
    19      {payload: {}, endpoint: `oauth/v2/service_instances/${instanceID}`, method: 'get'},
    20      {payload: {}, endpoint: `runtimes`, method: 'get'},
    21      {payload: {}, endpoint: `info/runtimes`, method: 'get'},
    22      {payload: {}, endpoint: `orchestrations`, method: 'get'},
    23      {payload: {}, endpoint: `oauth/${platformRegion}v2/service_instances/${instanceID}`, method: 'put'},
    24      {payload: {}, endpoint: `upgrade/cluster`, method: 'post'},
    25      {payload: {}, endpoint: `upgrade/kyma`, method: 'post'},
    26      {payload: {}, endpoint: `oauth/v2/service_instances/${instanceID}`, method: 'patch'},
    27      {payload: {}, endpoint: `oauth/v2/service_instances/${instanceID}`, method: 'delete'},
    28    ];
    29  
    30    it('Should reject call without authorization', async function() {
    31      for (const test of testData) {
    32        await testEndpointWithoutToken(test.payload, test.endpoint, test.method);
    33      }
    34    });
    35  });
    36