Skip to content

Commit

Permalink
Merge pull request #99 from vsalbaba/undertow_global_settings
Browse files Browse the repository at this point in the history
Undertow global settings
  • Loading branch information
kstekovi authored Aug 3, 2023
2 parents ed634c4 + b06ea42 commit 3680331
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/manual-test-matrix-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
"homepage",
"smoke",
"update-manager",
"undertow",
]
exclude:
- specs: "update-manager"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/scheduled-run-all-tests-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
"homepage",
"smoke",
"update-manager",
"undertow",
]
exclude:
- specs: "update-manager"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
describe("TESTS: Configuration => Subsystem => Undertow => Global settings", () => {
let managementEndpoint: string;
const address = ["subsystem", "undertow"];
const globalSettingsForm = {
formId: "undertow-global-settings-form",
defaultSecurityDomain: "default-security-domain",
defaultServer: "default-server",
defaultServletContainer: "default-servlet-container",
defaultVirtualHost: "default-virtual-host",
instanceId: "instance-id",
statisticsEnabled: "statistics-enabled",
};
const testValues = {
serverName: "new-server",
servletContainer: "new-servlet-container",
serverHost: "new-host-in-new-server",
instanceId: "new-instaince-id",
statisticsEnabledExpression: "${wildfly.statistics-enabled:true}",
};

before(() => {
cy.startWildflyContainer()
.then((result) => {
managementEndpoint = result as string;
})
.then(() => {
// create fixtures
cy.task("execute:cli", {
managementApi: managementEndpoint + "/management",
address: ["subsystem", "undertow", "server", testValues.serverName],
operation: "add",
});
cy.task("execute:cli", {
managementApi: managementEndpoint + "/management",
address: ["subsystem", "undertow", "servlet-container", testValues.servletContainer],
operation: "add",
});
cy.task("execute:cli", {
managementApi: managementEndpoint + "/management",
address: ["subsystem", "undertow", "server", testValues.serverName, "host", testValues.serverHost],
operation: "add",
});
});
});

after(() => {
cy.task("stop:containers");
});

beforeEach(() => {
cy.navigateTo(managementEndpoint, "undertow");
// the form takes a brief moment to initialize
cy.wait(200);
});

it("Should update the default security domain configuration ", () => {
cy.editForm(globalSettingsForm.formId);
cy.text(globalSettingsForm.formId, globalSettingsForm.defaultSecurityDomain, "some test value");
cy.saveForm(globalSettingsForm.formId);
cy.verifySuccess();
cy.verifyAttribute(managementEndpoint, address, "default-security-domain", "some test value");
});

it("Should update the default server configuration", () => {
cy.editForm(globalSettingsForm.formId);
cy.text(globalSettingsForm.formId, globalSettingsForm.defaultServer, testValues.serverName);
cy.saveForm(globalSettingsForm.formId);
cy.verifySuccess();
cy.verifyAttribute(managementEndpoint, address, "default-server", testValues.serverName);
});

it("Should update the default servlet container configuration", () => {
cy.editForm(globalSettingsForm.formId);
cy.text(globalSettingsForm.formId, globalSettingsForm.defaultServletContainer, testValues.servletContainer);
cy.saveForm(globalSettingsForm.formId);
cy.verifySuccess();
cy.verifyAttribute(managementEndpoint, address, "default-servlet-container", testValues.servletContainer);
});

it("Should update the default virtual host configuration", () => {
cy.editForm(globalSettingsForm.formId);
cy.text(globalSettingsForm.formId, globalSettingsForm.defaultVirtualHost, testValues.serverHost);
cy.saveForm(globalSettingsForm.formId);
cy.verifySuccess();
cy.verifyAttribute(managementEndpoint, address, "default-virtual-host", testValues.serverHost);
});

it("Should update the instance ID configuration", () => {
cy.editForm(globalSettingsForm.formId);
cy.text(globalSettingsForm.formId, globalSettingsForm.instanceId, testValues.instanceId);
cy.saveForm(globalSettingsForm.formId);
cy.verifySuccess();
cy.verifyAttribute(managementEndpoint, address, "instance-id", testValues.instanceId);
});

it("Should update the statistics-enabled configuration by changing the expression", () => {
cy.editForm(globalSettingsForm.formId);
const expressionFormInputSelector = "input#undertow-global-settings-form-statistics-enabled-editing.form-control";
cy.textExpression(
globalSettingsForm.formId,
globalSettingsForm.statisticsEnabled,
testValues.statisticsEnabledExpression,
{
selector: expressionFormInputSelector,
}
);

cy.saveForm(globalSettingsForm.formId);
cy.verifySuccess();
cy.verifyAttributeAsExpression(
managementEndpoint,
address,
"statistics-enabled",
testValues.statisticsEnabledExpression
);
});

it("Should update the statistics-enabled configuration by flipping the switch", () => {
cy.editForm(globalSettingsForm.formId);
cy.get('button[title="Switch to normal mode"]').click();
cy.flip(globalSettingsForm.formId, "statistics-enabled", false);
cy.saveForm(globalSettingsForm.formId);
cy.verifySuccess();
cy.verifyAttribute(managementEndpoint, address, "statistics-enabled", true);
});
});
51 changes: 45 additions & 6 deletions packages/testsuite/cypress/support/form-editing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,27 @@ Cypress.Commands.add("flip", (formId, attributeName, value) => {
});
});

Cypress.Commands.add("text", (formId, attributeName, value) => {
cy.formInput(formId, attributeName).click({ force: true }).wait(200).clear();
cy.formInput(formId, attributeName).type(value as string);
cy.formInput(formId, attributeName).should("have.value", value);
cy.formInput(formId, attributeName).trigger("change");
Cypress.Commands.add(
"text",
(formId, attributeName, value, options = { selector: "", parseSpecialCharSequences: true }) => {
const selector = options.selector;
const parseSpecialCharSequences = options.parseSpecialCharSequences;
let formInput;
if (selector) {
formInput = cy.get(selector);
} else {
formInput = cy.formInput(formId, attributeName);
}

formInput.click({ force: true }).wait(200).clear();
formInput.type(value as string, { parseSpecialCharSequences: parseSpecialCharSequences });
formInput.should("have.value", value);
formInput.trigger("change");
}
);

Cypress.Commands.add("textExpression", (formId, attributeName, value, options = { selector: "" }) => {
cy.text(formId, attributeName, value, { selector: options.selector, parseSpecialCharSequences: false });
});

Cypress.Commands.add("clearAttribute", (formId, attributeName) => {
Expand Down Expand Up @@ -222,8 +238,31 @@ declare global {
* @param formId - The ID of section which contain form inputs.
* @param attributeName - specific ID part of form input with text form input.
* @param value - the value which needs to be write to form input.
* @param options - an object which might contain any of the following:
* - a custom selector for text field (the name of the text field will not be guessed)
*/
text(
formId: string,
attributeName: string,
value: string | number,
options?: { selector?: string; parseSpecialCharSequences?: boolean }
): Chainable<void>;
/**
* Set text value to form input.
* @category Data inserting
*
* @param formId - The ID of section which contain form inputs.
* @param attributeName - specific ID part of form input with text form input.
* @param value - the value which needs to be write to form input.
* @param options - an object which might contain any of the following:
* - a custom selector for text field (the name of the text field will not be guessed)
*/
text(formId: string, attributeName: string, value: string | number): Chainable<void>;
textExpression(
formId: string,
attributeName: string,
value: string | number,
options?: { selector?: string }
): Chainable<void>;
/**
* Clear all selected list attribute items from the form input.
* @category Data removing
Expand Down
20 changes: 20 additions & 0 deletions packages/testsuite/cypress/support/resource-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ Cypress.Commands.add("readAttributeAsObjectList", (managementEndpoint, address,
});
});

Cypress.Commands.add("readAttributeAsExpression", (managementEndpoint, address, name) => {
cy.readAttributeAsObject(managementEndpoint, address, name).then((result) => {
return (result as { EXPRESSION_VALUE: string })["EXPRESSION_VALUE"];
});
});

Cypress.Commands.add("writeAttribute", (managementEndpoint, address, name, value) => {
cy.task("execute:cli", {
managementApi: managementEndpoint + "/management",
Expand Down Expand Up @@ -279,6 +285,20 @@ declare global {
name: string,
value: string | boolean | number
): Chainable<object[]>;

/**
* Executes :read-attribute operation at given address and attribute name.
* The managementEndpoint API is expected to return JSON with key "EXPRESSION_VALUE"
* Returns read value as string.
*
* @param managementEndpoint - Management endpoint of the WildFly server container instance.
* @param address - CLI address of subsystem.
* @param name - name of attribute from subsystem configuration. The attribute value is expected to be an expression
*
* @returns The the attribute value of subsystem configuration as string.
*/
readAttributeAsExpression(managementEndpoint: string, address: string[], name: string): Chainable<string>;

/**
* Get HTML element from form.
* @category Get value
Expand Down
22 changes: 22 additions & 0 deletions packages/testsuite/cypress/support/verification-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ Cypress.Commands.add("verifyRemovedFromTable", (tableId, resourceName) => {
cy.get(`${tableWrapper} td:contains("${resourceName}")`).should("not.exist");
});

Cypress.Commands.add("verifyAttributeAsExpression", (managementEndpoint, address, attributeName, expectedValue) => {
cy.readAttributeAsExpression(managementEndpoint, address, attributeName).then((result) => {
expect(result).to.equal(expectedValue);
});
});

export {};

declare global {
Expand Down Expand Up @@ -152,6 +158,22 @@ declare global {
* @param resourceName - The name of a resource
*/
verifyRemovedFromTable(tableId: string, resourceName: string): void;

/**
* Verify the specific configuration is saved.
* @category Verification
*
* @param managementEndpoint - Host name of currently used container.
* @param address - CLI address of subsystem which needs to be verified.
* @param attributeName - Attribute of subsystem which needs to be verified.
* @param expectedValue - The expected value of the attribute. The value is expected to be an expression
*/
verifyAttributeAsExpression(
managementEndpoint: string,
address: string[],
attributeName: string,
expectedValue: string
): void;
}
}
}

0 comments on commit 3680331

Please sign in to comment.