Skip to content

Commit

Permalink
fixes for contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
Celiant committed Jan 22, 2025
1 parent 10bbe2e commit f456e04
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ context("Contracts", { tags: ['contracts', 'firstPool', 'all'] }, () => {
})

it("Reject wipe contract requests without auth token - Negative", () => {
Authorization.getAccessToken(SRUsername).then((authorization) => {
cy.request({
method: METHOD.DELETE,
url: API.ApiServer + API.WipeRequests + wipeRequestId + "/" + API.Reject,
failOnStatusCode: false,
}).then((response) => {
expect(response.status).eql(STATUS_CODE.UNAUTHORIZED);
});
cy.request({
method: METHOD.DELETE,
url: API.ApiServer + API.WipeRequests + wipeRequestId + "/" + API.Reject,
failOnStatusCode: false,
}).then((response) => {
expect(response.status).eql(STATUS_CODE.UNAUTHORIZED);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ context("Contracts", { tags: ['contracts', 'firstPool', 'all'] }, () => {
let waitForApproveApplicationBlockId, deviceGridBlockId, issueRequestGridBlockId;


before("Create contracts, policy and register new user", () => {
before("Get contracts, policy and register new user", () => {
//Create retire contract and save id
Authorization.getAccessToken(SRUsername).then((authorization) => {
cy.request({
Expand Down Expand Up @@ -182,75 +182,75 @@ context("Contracts", { tags: ['contracts', 'firstPool', 'all'] }, () => {

before("Mint token", () => {
//Choose role
Authorization.getAccessToken(UserUsername).then((authorization) => {
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.Policies + policyId + "/" + API.ChooseRegistrantRole,
headers: {
authorization
},
body: {
role: "Registrant"
}
})

cy.wait(10000)

//Create app and wait while it in progress
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.Policies + policyId + "/" + API.CreateApplication,
headers: {
authorization
},
body: {
document: {
field1: {},
field2: {},
field3: {}
},
ref: null
}
})

let requestForApplicationCreationProgress = {
method: METHOD.GET,
url: API.ApiServer + API.Policies + policyId + "/" + API.Blocks + waitForApproveApplicationBlockId,
headers: {
authorization
}
}

Checks.whileApplicationCreating("Submitted for Approval", requestForApplicationCreationProgress, 0)
Authorization.getAccessToken(UserUsername).then((authorization) => {
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.Policies + policyId + "/" + API.ChooseRegistrantRole,
headers: {
authorization
},
body: {
role: "Registrant"
}
})

cy.wait(10000)

//Create app and wait while it in progress
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.Policies + policyId + "/" + API.CreateApplication,
headers: {
authorization
},
body: {
document: {
field1: {},
field2: {},
field3: {}
},
ref: null
}
})

let requestForApplicationCreationProgress = {
method: METHOD.GET,
url: API.ApiServer + API.Policies + policyId + "/" + API.Blocks + waitForApproveApplicationBlockId,
headers: {
authorization
}
}

Checks.whileApplicationCreating("Submitted for Approval", requestForApplicationCreationProgress, 0)
})
//Get applications data and prepare body for approve
let applicationData
Authorization.getAccessToken(SRUsername).then((authorization) => {
cy.request({
method: METHOD.GET,
url: API.ApiServer + API.Policies + policyId + "/" + API.GetApplications,
headers: {
authorization
}
}).then((response) => {
applicationData = response.body.data[0];
applicationData.option.status = "Approved"
let appDataBody = JSON.stringify({
document: applicationData,
tag: "Button_0"
})
//Get applications data and prepare body for approve
let applicationData
Authorization.getAccessToken(SRUsername).then((authorization) => {
cy.request({
method: METHOD.GET,
url: API.ApiServer + API.Policies + policyId + "/" + API.GetApplications,
headers: {
authorization
}
}).then((response) => {
applicationData = response.body.data[0];
applicationData.option.status = "Approved"
let appDataBody = JSON.stringify({
document: applicationData,
tag: "Button_0"
})
//Approve app
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.Policies + policyId + "/" + API.ApproveApplication,
headers: {
authorization,
"content-type": "application/json"
},
body: appDataBody
})
})
//Approve app
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.Policies + policyId + "/" + API.ApproveApplication,
headers: {
authorization,
"content-type": "application/json"
},
body: appDataBody
})
})
})
//Wait while approve in progress
Authorization.getAccessToken(UserUsername).then((authorization) => {
let requestForApplicationApproveProgress = {
Expand Down Expand Up @@ -432,7 +432,9 @@ context("Contracts", { tags: ['contracts', 'firstPool', 'all'] }, () => {
Checks.whileBalanceVerifying("10", requestForBalance, 91, tokenId)
})
})




it("Disable wipe contract requests", () => {
Authorization.getAccessToken(SRUsername).then((authorization) => {
cy.request({
Expand Down Expand Up @@ -656,6 +658,42 @@ context("Contracts", { tags: ['contracts', 'firstPool', 'all'] }, () => {
});
});

it("Approve wipe contract requests without auth token - Negative", () => {
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.WipeRequests + wipeRequestId + "/" + API.Approve,
failOnStatusCode: false,
}).then((response) => {
expect(response.status).eql(STATUS_CODE.UNAUTHORIZED);
});
});

it("Approve wipe contract requests with invalid auth token - Negative", () => {
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.WipeRequests + wipeRequestId + "/" + API.Approve,
headers: {
authorization: "Bearer wqe",
},
failOnStatusCode: false,
}).then((response) => {
expect(response.status).eql(STATUS_CODE.UNAUTHORIZED);
});
});

it("Approve wipe contract requests with empty auth token - Negative", () => {
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.WipeRequests + wipeRequestId + "/" + API.Approve,
headers: {
authorization: "",
},
failOnStatusCode: false,
}).then((response) => {
expect(response.status).eql(STATUS_CODE.UNAUTHORIZED);
});
});

it("Approve wipe contract requests", () => {
Authorization.getAccessToken(SRUsername).then((authorization) => {
cy.request({
Expand All @@ -681,6 +719,7 @@ context("Contracts", { tags: ['contracts', 'firstPool', 'all'] }, () => {
});
});
})
cy.wait(30000)
Authorization.getAccessToken(UserUsername).then((authorization) => {
cy.request({
method: METHOD.GET,
Expand All @@ -694,40 +733,4 @@ context("Contracts", { tags: ['contracts', 'firstPool', 'all'] }, () => {
})
})
})

it("Approve wipe contract requests without auth token - Negative", () => {
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.WipeRequests + wipeRequestId + "/" + API.Approve,
failOnStatusCode: false,
}).then((response) => {
expect(response.status).eql(STATUS_CODE.UNAUTHORIZED);
});
});

it("Approve wipe contract requests with invalid auth token - Negative", () => {
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.WipeRequests + wipeRequestId + "/" + API.Approve,
headers: {
authorization: "Bearer wqe",
},
failOnStatusCode: false,
}).then((response) => {
expect(response.status).eql(STATUS_CODE.UNAUTHORIZED);
});
});

it("Approve wipe contract requests with empty auth token - Negative", () => {
cy.request({
method: METHOD.POST,
url: API.ApiServer + API.WipeRequests + wipeRequestId + "/" + API.Approve,
headers: {
authorization: "",
},
failOnStatusCode: false,
}).then((response) => {
expect(response.status).eql(STATUS_CODE.UNAUTHORIZED);
});
});
})

0 comments on commit f456e04

Please sign in to comment.