Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add binding SKR test for response codes #1369

Merged
merged 6 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions testing/e2e/skr/kyma-environment-broker/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,35 +283,20 @@ class KEBClient {
};
const endpoint = `service_instances/${instanceID}/service_bindings/${bindingID}?accepts_incomplete=false`;
const config = await this.buildRequest(payload, endpoint, 'put');

try {
return await axios.request(config);
} catch (err) {
throw err;
}
return await axios.request(config);
}

async deleteBinding(instanceID, bindingID) {
const params = `service_id=${KYMA_SERVICE_ID}&plan_id=${this.planID}`;
const endpoint = `service_instances/${instanceID}/service_bindings/${bindingID}?accepts_incomplete=false&${params}`;
const config = await this.buildRequest({}, endpoint, 'delete');

try {
return await axios.request(config);
} catch (err) {
throw err;
}
return await axios.request(config);
}

async getBinding(instanceID, bindingID) {
const endpoint = `service_instances/${instanceID}/service_bindings/${bindingID}?accepts_incomplete=false`;
const config = await this.buildRequest({}, endpoint, 'get');

try {
return await axios.request(config);
} catch (err) {
throw err;
}
return await axios.request(config);
}

getPlatformRegion() {
Expand Down
64 changes: 63 additions & 1 deletion testing/e2e/skr/skr-binding-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ describe('SKR Binding test', function() {
try {
const resp = await keb.createBinding(options.instanceID, bindingID);
kubeconfigFromBinding = resp.data.credentials.kubeconfig;
expect(resp.status).equal(201);
} catch (err) {
console.log(err);
throw err;
}
});

Expand All @@ -51,6 +52,7 @@ describe('SKR Binding test', function() {
it('Get SKR binding', async function() {
const resp = await keb.getBinding(options.instanceID, bindingID);
expect(resp.data.credentials.kubeconfig).to.equal(kubeconfigFromBinding);
expect(resp.status).equal(200);
});

it('Delete SKR binding', async function() {
Expand Down Expand Up @@ -121,6 +123,66 @@ describe('SKR Binding test', function() {
}
});

it('Should return HTTP 200 when creating a binding with the same ID and params as an existing one', async function() {
bindingID = uuid.v4();
const expirationSeconds = 600;
const firstResponse = await keb.createBinding(options.instanceID, bindingID, expirationSeconds);
expect(firstResponse.status).equal(201);

const secondResponse = await keb.createBinding(options.instanceID, bindingID, expirationSeconds);
expect(secondResponse.status).equal(200);
});

it('Should return HTTP 409 for creating duplicate binding but with different params', async function() {
const expirationSeconds = 700;
try {
await keb.createBinding(options.instanceID, bindingID, expirationSeconds);
expect.fail('The call was expected to return HTTP 409');
} catch (err) {
if (err.response) {
expect(err.response.status).equal(409);
expect(err.response.data.description).to.include('binding already exists but with different parameters');
console.log('Got response:');
console.log(err.response.data);
} else {
throw err;
}
}
});

it('Should return HTTP 410 when deleting a nonexisting binding', async function() {
try {
const resp = await keb.deleteBinding(options.instanceID, bindingID);
expect(resp.status).equal(200);
await keb.deleteBinding(options.instanceID, bindingID);
expect.fail('The call was expected to return HTTP 410');
} catch (err) {
if (err.response) {
expect(err.response.status).equal(410);
console.log('Got response:');
console.log(err.response.data);
} else {
throw err;
}
}
});

it('Should return HTTP 404 when trying to get a nonexisting binding', async function() {
try {
await keb.getBinding(options.instanceID, bindingID);
expect.fail('The call was expected to return HTTP 404');
} catch (err) {
if (err.response) {
expect(err.response.status).equal(404);
expect(err.response.data.description).to.include('Binding not found');
console.log('Got response:');
console.log(err.response.data);
} else {
throw err;
}
}
});

it('Should not allow creation of more than 10 SKR bindings', async function() {
let errorOccurred = false;
let count = 0;
Expand Down
Loading