diff --git a/testing/e2e/skr/kyma-environment-broker/client.js b/testing/e2e/skr/kyma-environment-broker/client.js index c1e042073b..368bee0b2b 100644 --- a/testing/e2e/skr/kyma-environment-broker/client.js +++ b/testing/e2e/skr/kyma-environment-broker/client.js @@ -284,10 +284,12 @@ class KEBClient { }; const bindingID = Math.random().toString(36).substring(2, 18); const endpoint = `service_instances/${instanceID}/service_bindings/${bindingID}?accepts_incomplete=true`; + const config = await this.buildRequest(payload, endpoint, 'put'); + try { - return await this.callKEB(payload, endpoint, 'put'); + return await axios.request(config); } catch (err) { - throw new Error(`error while creating binding: ${err.toString()}`); + throw err; } } diff --git a/testing/e2e/skr/skr-binding-test/index.js b/testing/e2e/skr/skr-binding-test/index.js index 54b254b6f1..27c9dbdd13 100644 --- a/testing/e2e/skr/skr-binding-test/index.js +++ b/testing/e2e/skr/skr-binding-test/index.js @@ -30,14 +30,15 @@ describe('SKR Binding test', function() { it('Create SKR binding for service account using Kubernetes TokenRequest', async function() { try { - kubeconfigFromBinding = await keb.createBinding(options.instanceID, true); + const resp = await keb.createBinding(options.instanceID, true); + kubeconfigFromBinding = resp.data.credentials.kubeconfig; } catch (err) { console.log(err); } }); it('Initiate K8s client with kubeconfig from binding', async function() { - await initializeK8sClient({kubeconfig: kubeconfigFromBinding.credentials.kubeconfig}); + await initializeK8sClient({kubeconfig: kubeconfigFromBinding}); }); it('Fetch sap-btp-manager secret using binding for service account from Kubernetes TokenRequest', async function() { @@ -47,21 +48,56 @@ describe('SKR Binding test', function() { it('Create SKR binding using Gardener', async function() { const expirationSeconds = 900; try { - kubeconfigFromBinding = await keb.createBinding(options.instanceID, false, expirationSeconds); - expect(getKubeconfigValidityInSeconds(kubeconfigFromBinding.credentials.kubeconfig)).to.equal(expirationSeconds); + const resp = await keb.createBinding(options.instanceID, false, expirationSeconds); + kubeconfigFromBinding = resp.data.credentials.kubeconfig; + expect(getKubeconfigValidityInSeconds(kubeconfigFromBinding)).to.equal(expirationSeconds); } catch (err) { console.log(err); } }); it('Initiate K8s client with kubeconfig from binding', async function() { - await initializeK8sClient({kubeconfig: kubeconfigFromBinding.credentials.kubeconfig}); + await initializeK8sClient({kubeconfig: kubeconfigFromBinding}); }); it('Fetch sap-btp-manager secret using binding from Gardener', async function() { await getSecret(secretName, ns); }); + it('Should not allow creation of SKR binding when expiration seconds value is below the min value', async function() { + const expirationSeconds = 1; + try { + await keb.createBinding(options.instanceID, true, expirationSeconds); + expect.fail('The call was expected to fail but it passed'); + } catch (err) { + if (err.response) { + expect(err.response.status).equal(400); + expect(err.response.data.description).to.include('expiration_seconds cannot be less than'); + console.log('Got response:'); + console.log(err.response.data); + } else { + throw err; + } + } + }); + + it('Should not allow creation of SKR binding when expiration seconds value is over the max value', async function() { + const expirationSeconds = 999999999; + try { + await keb.createBinding(options.instanceID, true, expirationSeconds); + expect.fail('The call was expected to fail but it passed'); + } catch (err) { + if (err.response) { + expect(err.response.status).equal(400); + expect(err.response.data.description).to.include('expiration_seconds cannot be greater than'); + console.log('Got response:'); + console.log(err.response.data); + } else { + throw err; + } + } + }); + after('Cleanup the resources', async function() { this.timeout(deprovisioningTimeout); if (process.env['SKIP_DEPROVISIONING'] != 'true') {