Skip to content
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
7 changes: 7 additions & 0 deletions .github/workflows/api-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ jobs:
with:
node-version: "16"

- name: Install bruno
run: npm install -g @usebruno/cli

- name: Run tests
run: bru run --env "Admin API Docker" --insecure
working-directory: ./Application/EdFi.Ods.AdminApi/E2E Tests/bruno/Admin API E2E

- name: Install newman
run: npm install -g newman newman-reporter-junitfull

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
meta {
name: Get Token
type: http
seq: 1
}

post {
url: {{API_URL}}/connect/token
body: formUrlEncoded
auth: none
}

body:form-urlencoded {
grant_type: client_credentials
client_id: %7B%7BClientId%7D%7D
client_secret: %7B%7BClientSecret%7D%7D
scope: edfi_admin_api%2Ffull_access
}

script:post-response {
bru.setEnvVar("AT",res.body.access_token);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
meta {
name: Landing Page
type: http
seq: 1
}

get {
url: {{API_URL}}
body: json
auth: none
}

assert {
res.status: eq 200
}

tests {

test("Response includes expected properties", function() {
const data = res.getBody();
expect(data).to.have.property("version");
expect(data).to.have.property("build");
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
meta {
name: Register - Already Exists
type: http
seq: 3
}

post {
url: {{API_URL}}/connect/register
body: formUrlEncoded
auth: none
}

body:form-urlencoded {
ClientId: %7B%7BRegisteredClientId%7D%7D
ClientSecret: %7B%7BRegisteredClientSecret%7D%7D
DisplayName: %7B%7BUserName%7D%7D
}

tests {
// pm.test("Status code is Bad Request", function () {
// pm.response.to.have.status(400);
// });
//
// const response = pm.response.json();
//
// pm.test("Response matches error format", function () {
// pm.expect(response.status).to.equal(400);
// pm.expect(response).to.have.property("title");
// pm.expect(response).to.have.property("errors");
// });
//
// pm.test("Response title is helpful and accurate", function () {
// pm.expect(response.title.toLowerCase()).to.contain("validation");
// });
//
// pm.test("Response errors include messages by property", function () {
// pm.expect(response.errors.ClientId.length).to.equal(1);
// pm.expect(response.errors.ClientId[0]).to.contain("already exists");
// });
//
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
meta {
name: Register - Invalid
type: http
seq: 2
}

post {
url: {{API_URL}}/connect/register
body: formUrlEncoded
auth: none
}

body:form-urlencoded {
ClientId:
ClientSecret:
DisplayName:
}

assert {
res.status: eq 400
res.body.title: eq Validation failed
res.body.errors: isJson {}
}

tests {
test("Response includes validation errors", function() {
const data = res.getBody();
const validationErrors = {
"ClientId": [
"'Client Id' must not be empty."
],
"ClientSecret": [
"'Client Secret' must not be empty."
],
"DisplayName": [
"'Display Name' must not be empty."
]
};
expect(data.errors).deep.equal(validationErrors);

});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
meta {
name: Register
type: http
seq: 1
}

post {
url: {{API_URL}}/connect/register
body: formUrlEncoded
auth: none
}

assert {
res.status: eq 200
res.body.title: contains Registered client
}

script:pre-request {
const { nanoid } = require("nanoid");

const clientId = nanoid();
const clientSecret = nanoid();
const displayName = "Test";

req.setBody({
clientId,
clientSecret,
displayName
});

bru.setVar('ClientId', clientId);
bru.setVar('ClientSecret', clientSecret);
}

docs {
# Register

Registers a new user
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
meta {
name: Token - Incorrect Secret
type: http
seq: 8
}

post {
url: {{API_URL}}/connect/token
body: formUrlEncoded
auth: none
}

body:form-urlencoded {
client_id: %7B%7BRegisteredClientId%7D%7D
client_secret: %7B%7B%24guid%7D%7D
grant_type: client_credentials
scope: edfi_admin_api%2Ffull_access
}

script:pre-request {
//
}

tests {
// pm.test("Status code is Unauthorized", function () {
// pm.response.to.have.status(401);
// });
//
// const response = pm.response.json();
//
// pm.test("Response includes error message", function () {
// pm.expect(response).to.have.property("error");
// pm.expect(response).to.have.property("error_description");
// pm.expect(response).to.have.property("error_uri");
//
// pm.expect(response["error_description"]).to.contain("credentials");
// pm.expect(response["error_description"]).to.contain("invalid");
// });
//
// pm.collectionVariables.unset("RegisteredClientId");
// pm.collectionVariables.unset("RegisteredClientSecret");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
meta {
name: Token - Invalid Grant Type
type: http
seq: 6
}

post {
url: {{API_URL}}/connect/token
body: formUrlEncoded
auth: none
}

body:form-urlencoded {
client_id: %7B%7BRegisteredClientId%7D%7D
client_secret: %7B%7BRegisteredClientSecret%7D%7D
grant_type: authorization_code
scope: edfi_admin_api%2Ffull_access
}

tests {
// pm.test("Status code is Bad Request", function () {
// pm.response.to.have.status(400);
// });
//
// const response = pm.response.json();
//
// pm.test("Response includes error message", function () {
// pm.expect(response).to.have.property("error");
// pm.expect(response).to.have.property("error_description");
// pm.expect(response).to.have.property("error_uri");
//
// pm.expect(response["error_description"]).to.contain("grant_type");
// });
//
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
meta {
name: Token - Invalid Scope
type: http
seq: 7
}

post {
url: {{API_URL}}/connect/token
body: formUrlEncoded
auth: none
}

body:form-urlencoded {
client_id: %7B%7BRegisteredClientId%7D%7D
client_secret: %7B%7B%24guid%7D%7D
grant_type: client_credentials
scope: NOT_REAL%2FSCOPE
}

script:pre-request {
//
}

tests {
// pm.test("Status code is Bad Request", function () {
// pm.response.to.have.status(400);
// });
//
// const response = pm.response.json();
//
// pm.test("Response includes error message", function () {
// pm.expect(response).to.have.property("error");
// pm.expect(response).to.have.property("error_description");
// pm.expect(response).to.have.property("error_uri");
//
// pm.expect(response["error_description"]).to.contain("scope");
// });
//
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
meta {
name: Token - Invalid
type: http
seq: 5
}

post {
url: {{API_URL}}/connect/token
body: formUrlEncoded
auth: none
}

body:form-urlencoded {
client_id: %7B%7B%24guid%7D%7D
client_secret:
grant_type: client_credentials
}

tests {
// pm.test("Status code is Bad Request", function () {
// pm.response.to.have.status(400);
// });
//
// const response = pm.response.json();
//
// pm.test("Response includes error message", function () {
// pm.expect(response).to.have.property("error");
// pm.expect(response).to.have.property("error_description");
// pm.expect(response).to.have.property("error_uri");
// });
//
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
meta {
name: Token
type: http
seq: 4
}

post {
url: {{API_URL}}/connect/token
body: formUrlEncoded
auth: none
}

body:form-urlencoded {
client_id: %7B%7BRegisteredClientId%7D%7D
client_secret: %7B%7BRegisteredClientSecret%7D%7D
grant_type: client_credentials
scope: edfi_admin_api%2Ffull_access
}

tests {
// pm.test("Status code is OK", function () {
// pm.response.to.have.status(200);
// });
//
// const response = pm.response.json();
//
// pm.test("Response includes token", function () {
// pm.expect(response).to.have.property("access_token");
// pm.expect(response).to.have.property("token_type");
// pm.expect(response).to.have.property("expires_in");
//
// pm.expect(response["token_type"]).to.equal("Bearer");
// });
//
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": "1",
"name": "Admin API E2E",
"type": "collection"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vars {
API_URL: https://localhost/adminapi
}
Loading