Added command for seeding queries (#1061)

* Closes #922

* #922 added Windows section to build docs

* go sum updated

* updated go sum

* fixed #963 - calling teams api if not on core

* added command for seeding queries

* added command default to higher level

* linted test

* only need 2 queries
This commit is contained in:
Martavis Parker 2021-06-11 14:27:19 -07:00 committed by GitHub
parent e7cffa221d
commit 172fbbb43f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 0 deletions

View file

@ -4,6 +4,7 @@ if (Cypress.env("FLEET_TIER") === "basic") {
cy.setup();
cy.login();
cy.seedBasic();
cy.seedQueries();
cy.logout();
});
@ -16,5 +17,26 @@ if (Cypress.env("FLEET_TIER") === "basic") {
// TODO write the test!
});
it("Should verify Teams on Hosts page", () => {
cy.login("marco@organization.com", "user123#");
cy.visit("/hosts/manage");
cy.findByText("All hosts which have enrolled in Fleet").should("exist");
// TODO: can see the "Team" column in the Hosts table
// cy.contains(".table-container .data-table__table th", "Team").should("be.visible");
});
it("Should verify hidden items on Hosts page", () => {
cy.login("marco@organization.com", "user123#");
cy.visit("/hosts/manage");
cy.findByText("Packs").should("not.exist");
cy.findByText("Queries").should("not.exist");
// TODO: can see the "Team" column in the Hosts table
// cy.contains(".table-container .data-table__table th", "Team").should("be.visible");
});
});
}

View file

@ -53,6 +53,38 @@ Cypress.Commands.add("logout", () => {
});
});
Cypress.Commands.add("seedQueries", () => {
const queries = [
{
name: "Detect presence of authorized SSH keys",
query:
"SELECT username, authorized_keys. * FROM users CROSS JOIN authorized_keys USING (uid)",
description:
"Presence of authorized SSH keys may be unusual on laptops. Could be completely normal on servers, but may be worth auditing for unusual keys and/or changes.",
observer_can_run: true,
},
{
name: "Get authorized keys for Domain Joined Accounts",
query:
"SELECT * FROM users CROSS JOIN authorized_keys USING(uid) WHERE username IN (SELECT distinct(username) FROM last);",
description: "List authorized_keys for each user on the system.",
observer_can_run: false,
},
];
queries.forEach((queryForm) => {
const { name, query, description, observer_can_run } = queryForm;
cy.request({
url: "/v1/fleet/queries",
method: "POST",
body: { name, query, description, observer_can_run },
auth: {
bearer: window.localStorage.getItem("FLEET::auth_token"),
},
});
});
});
Cypress.Commands.add("setupSMTP", () => {
const body = {
smtp_settings: {

View file

@ -18,6 +18,11 @@ declare namespace Cypress {
*/
logout(): Chainable<Element>;
/**
* Custom command to add new queries by default.
*/
seedQueries(): Chainable<Element>;
/**
* Custom command to add a new user in Fleet (via fleetctl).
*/