Skip to content

Commit

Permalink
ISPN-15198 Adapt the console to non admins
Browse files Browse the repository at this point in the history
* Cache distribution chart is for admins
* Configuration is not visible for admins
* Indexing empty message display
* Connected clients is only visible for admins
  • Loading branch information
karesti committed Oct 3, 2023
1 parent 5dc4e2d commit 84e3ef1
Show file tree
Hide file tree
Showing 39 changed files with 1,064 additions and 748 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 18.17.0
node-version: 18.18.0
cache: 'npm'

- name: Install
Expand All @@ -35,6 +35,7 @@ jobs:
name: Start Infinispan Server Latest Version
run: |
docker run -d -p 11222:11222 -v ${{ github.workspace }}/scripts/identities.batch:/user-config/identities.batch -v ${{ github.workspace }}/dist:/opt/infinispan/static/console -v ${{ github.workspace }}/scripts/infinispan-basic-auth.xml:/opt/infinispan/server/conf/infinispan.xml -e JAVA_OPTIONS="-Xms1024m -Xmx3072m -XX:MetaspaceSize=1024m -XX:MaxMetaspaceSize=2048m" -e IDENTITIES_BATCH="/user-config/identities.batch" quay.io/infinispan-test/server:main --node-name=infinispan-4-e2e
# docker run -d -p 11222:11222 -v /Users/karestig/REDHAT/INFINISPAN/infinispan-console/scripts/identities.batch:/user-config/identities.batch -v /Users/karestig/REDHAT/INFINISPAN/infinispan-console/dist:/opt/infinispan/static/console -v /Users/karestig/REDHAT/INFINISPAN/infinispan-console/scripts/infinispan-basic-auth.xml:/opt/infinispan/server/conf/infinispan.xml -e JAVA_OPTIONS="-Xms1024m -Xmx3072m -XX:MetaspaceSize=1024m -XX:MaxMetaspaceSize=2048m" -e IDENTITIES_BATCH="/user-config/identities.batch" quay.io/infinispan-test/server:main --node-name=infinispan-4-e2e
# Wait for server to startup
curl --fail --silent --show-error --retry-all-errors --retry 240 --retry-delay 1 http://localhost:11222/rest/v2/cache-managers/default/health/status > /dev/null
#Installing Nashorn dependencies
Expand Down Expand Up @@ -63,7 +64,7 @@ jobs:
# Wait for server to startup
curl --fail --silent --show-error --retry-all-errors --retry 240 --retry-delay 1 http://localhost:11222/rest/v2/cache-managers/default/health/status > /dev/null
- name: Initialize Infnispan Server
- name: Initialize Infinispan Server
run: cd data; bash ./create-data.sh admin password

- name: Cypress run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Welcome page', () => {
cy.contains('Default'); // cluster name
cy.contains('Running'); // cluster status
cy.contains('Cluster rebalancing on'); // rebalancing status
cy.contains('18 Caches');
cy.contains('15 Caches');
cy.contains('10 Counters');
cy.contains('1 Tasks');
cy.contains('13 Schemas');
Expand Down Expand Up @@ -72,7 +72,7 @@ describe('Welcome page', () => {
cy.login(Cypress.env('username'), Cypress.env('password'));
cy.get('[data-cy=aboutInfoQuestionMark]').click();
cy.contains('Documentation');

//Clicks the About link and should go to About dialog
cy.contains('About').click();
cy.get('[role=dialog]').should('be.visible');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('Data Container Overview', () => {
const numberOfCaches = 18;
const numberOfCaches = 15;

beforeEach(() => {
cy.login(Cypress.env('username'), Cypress.env('password'));
Expand Down Expand Up @@ -32,7 +32,7 @@ describe('Data Container Overview', () => {
//Testing pagination and navigation
it('successfully navigates through the caches as well as changes number of viewed caches on the page', () => {
cy.contains(numberOfCaches + ' Caches');
cy.contains('12 Counters');
cy.contains('10 Counters');
cy.contains('1 Tasks');
cy.contains('13 Schemas');

Expand Down Expand Up @@ -121,7 +121,7 @@ describe('Data Container Overview', () => {

//Verifying that only local caches are shown
cy.contains('default');
cy.get('[data-cy=cachesTable] tr').should('have.length', 3); //3 including header row
cy.get('[data-cy=cachesTable] tr').should('have.length', 2); //2 including header row
//Verifying that all entries are local caches
cy.get('[data-cy^=type-]').each((badge) => {
cy.wrap(badge).contains('Local');
Expand Down Expand Up @@ -171,12 +171,12 @@ describe('Data Container Overview', () => {
cy.get('[data-cy=cacheFilterSelect]').click();

//Verifying that only distributed caches are shown
cy.contains('1 - 10 of 14');
cy.contains('1 - 10 of 12');
cy.contains('java-serialized-cache');
cy.get('[data-cy=cachesTable] tr').should('have.length', 11); //11 including header row
//Navigating to the next page to see the rest of the caches
cy.get('[data-action=next]').first().click();
cy.get('[data-cy=cachesTable] tr').should('have.length', 5); //5 including header row
cy.get('[data-cy=cachesTable] tr').should('have.length', 3); //3 including header row
cy.contains('xml-cache');
cy.contains('java-serialized-cache').should('not.exist');

Expand All @@ -185,8 +185,8 @@ describe('Data Container Overview', () => {
cy.get('[data-action=per-page-20]').click();
cy.contains('not-encoded');
cy.contains('xml-cache');
cy.contains('1 - 14 of 14');
cy.get('[data-cy=cachesTable] tr').should('have.length', 15); //15 including header row
cy.contains('1 - 12 of 12');
cy.get('[data-cy=cachesTable] tr').should('have.length', 13); //13 including header row

//Verifying that all entries are distributed caches
cy.get('[data-cy^=type-]').each((badge) => {
Expand All @@ -198,7 +198,7 @@ describe('Data Container Overview', () => {
cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click();
cy.get('[data-cy="transactionalFeature"]').find('input:checkbox').click(); //Filtering transactional caches (already on filtered distributed caches)
cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); //Closing filter selectbox
cy.get('[data-cy=cachesTable] tr').should('have.length', 5); //5 including header row
cy.get('[data-cy=cachesTable] tr').should('have.length', 4); //4 including header row
// //Verifying that all entries are distributed and transactional caches
cy.get('[data-cy^=type-]').each((badge) => {
cy.wrap(badge).contains('Distributed');
Expand All @@ -209,13 +209,12 @@ describe('Data Container Overview', () => {
cy.contains('heap-test');
cy.contains('off-heap-test');
cy.contains('people');
cy.contains('super-cache');

// //Adding Replicated type filter
cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click();
cy.get('[data-cy="replicatedType"]').find('input:checkbox').click(); //Filtering transactional caches (already on filtered distributed caches)+replicated
cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); //Closing filter selectbox
cy.get('[data-cy=cachesTable] tr').should('have.length', 5); //5 including header row - nothing is changed
cy.get('[data-cy=cachesTable] tr').should('have.length', 4); //4 including header row - nothing is changed
//Verifying that all entries are distributed and transactional caches
cy.get('[data-cy^=type-]').each((badge) => {
cy.wrap(badge).contains('Distributed');
Expand All @@ -226,7 +225,6 @@ describe('Data Container Overview', () => {
cy.contains('heap-test');
cy.contains('off-heap-test');
cy.contains('people');
cy.contains('super-cache');

//Removing Distributed filter
cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click();
Expand All @@ -239,7 +237,7 @@ describe('Data Container Overview', () => {
cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click();
cy.get('[data-cy="replicatedType"]').find('input:checkbox').click(); //Filtering transactional caches & replicated ones
cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); //Closing filter selectbox
cy.get('[data-cy=cachesTable] tr').should('have.length', 5); //5 including header row - nothing is changed
cy.get('[data-cy=cachesTable] tr').should('have.length', 4); //4 including header row - nothing is changed
cy.get('[data-cy^=feature-]').each((badge) => {
cy.wrap(badge).contains('Transactional');
});
Expand All @@ -248,7 +246,7 @@ describe('Data Container Overview', () => {
cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click();
cy.get('[data-cy="indexedFeature"]').find('input:checkbox').click(); //Filtering transactional caches & replicated ones
cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); //Closing filter selectbox
cy.get('[data-cy=cachesTable] tr').should('have.length', 7); //7 including header row - nothing is changed
cy.get('[data-cy=cachesTable] tr').should('have.length', 7); //5 including header row - nothing is changed
cy.get('[data-cy^=feature-]').each((badge) => {
cy.wrap(badge).contains(/Transactional|Indexed/);
});
Expand All @@ -269,7 +267,6 @@ describe('Data Container Overview', () => {
cy.wrap(badge).contains(/Secured/);
});
cy.contains('indexed-cache');
cy.contains('super-cache');

//Clearing all filters and setting Persistence
cy.get('button:contains("Clear all filters"):visible').click();
Expand All @@ -280,94 +277,66 @@ describe('Data Container Overview', () => {
cy.get('[data-cy^=feature-]').each((badge) => {
cy.wrap(badge).contains(/Persistent/);
});
cy.contains('super-cache');

//Adding Bounded filter
cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click();
cy.get('[data-cy="boundedFeature"]').find('input:checkbox').click(); //Filtering bounded caches
cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click(); //Closing filter selectbox
cy.get('[data-cy=cachesTable] tr').should('have.length', 4); //4 including header row - nothing is changed
cy.get('[data-cy=cachesTable] tr').should('have.length', 3); //3 including header row - nothing is changed
cy.get('[data-cy^=feature-]').each((badge) => {
cy.wrap(badge).contains(/Bounded/);
});
cy.contains('super-cache');
cy.contains('heap-test');
});

//Hide created cache and check the hidden filter
it('successfully ignores the cache', () => {
cy.get('[data-cy=actions-aCache]').click();
cy.get('[data-cy=actions-default]').click();
cy.get('[aria-label=ignoreCacheAction]').click();
cy.get('[data-cy=ignoreCacheModal]').should('exist');
cy.get('#hideShowModal [aria-label=Close]').click(); //Closing modal with close button
cy.get('[data-cy=ignoreCacheModal]').should('not.exist');

cy.get('[data-cy=actions-aCache]').click();
cy.get('[data-cy=actions-default]').click();
cy.get('[aria-label=ignoreCacheAction]').click();
cy.get('[data-cy=ignoreCacheModal]').should('exist');
cy.get('[data-cy=cancelAction]').click(); //Closing modal with Cancel button
cy.get('[data-cy=ignoreCacheModal]').should('not.exist');
cy.get('[data-cy=actions-aCache]').click();
cy.get('[data-cy=actions-default]').click();
cy.get('[aria-label=ignoreCacheAction]').click();
cy.get('[data-cy=hideCacheButton]').click(); //Hiding cache

cy.contains('Cache aCache hidden.').should('exist');
cy.get('[data-cy=ignoreBadge-aCache]').should('exist');
cy.contains('Cache default hidden.').should('exist');
cy.get('[data-cy=ignoreBadge-default]').should('exist');

cy.get('[data-cy=cacheFilterSelect]').click();
cy.get('[data-cy=cacheFilterSelectExpanded] div > button').click();
cy.get('[data-cy="hiddenStatus"]').find('input:checkbox').click(); //Filtering hidden caches
cy.get('[data-cy=cacheFilterSelect]').click(); //Closing filter selectbox
cy.get('[data-cy=cachesTable] tr').should('have.length', 2); //2 including header row - nothing is changed
cy.get('[data-cy=ignoreBadge-aCache]').should('exist');
cy.contains('aCache');
cy.get('[data-cy=ignoreBadge-default]').should('exist');
cy.contains('default');
});

//Show (undo ignored cache) created cache
it('successfully undos the ignore the cache action', () => {
cy.get('[data-cy=actions-aCache]').click();
cy.get('[data-cy=actions-default]').click();
cy.get('[aria-label=showCacheAction]').click();
cy.get('[data-cy=undoCacheModal]').should('exist');
cy.get('#hideShowModal [aria-label=Close]').click(); //Closing modal with close button
cy.get('[data-cy=undoCacheModal]').should('not.exist');

cy.get('[data-cy=actions-aCache]').click();
cy.get('[data-cy=actions-default]').click();
cy.get('[aria-label=showCacheAction]').click();
cy.get('[data-cy=undoCacheModal]').should('exist');
cy.get('[data-cy=cancelAction]').click(); //Closing modal with Cancel button
cy.get('[data-cy=undoCacheModal]').should('not.exist');
cy.get('[data-cy=actions-aCache]').click();
cy.get('[data-cy=actions-default]').click();
cy.get('[aria-label=showCacheAction]').click();
cy.get('[data-cy=showCacheButton]').click(); //Hiding cache

cy.contains('Cache aCache is now visible.').should('exist');
cy.get('[data-cy=ignoreBadge-aCache]').should('not.exist');
});

//Delete created cache
it('successfully deletes a cache', () => {
cy.get('[data-cy=actions-aCache]').click();
cy.get('[aria-label=deleteCacheAction]').click();
cy.get('#deleteCacheModal').should('exist');
cy.contains('Permanently delete cache?');
cy.get('#deleteCacheModal [aria-label=Close]').click(); //Closing modal with close button
cy.contains('Permanently delete cache?').should('not.exist');

cy.get('[data-cy=actions-aCache]').click();
cy.get('[aria-label=deleteCacheAction]').click();
cy.contains('Permanently delete cache?');
cy.get('[data-cy=cancelCacheDeleteButton]').click(); //Closing modal with Cancel button
cy.contains('Permanently delete cache?').should('not.exist');

cy.get('[data-cy=actions-aCache]').click();
cy.get('[aria-label=deleteCacheAction]').click();
cy.get('#cache-to-delete').click();
cy.get('#cache-to-delete').type('aCache');
cy.get('[data-cy=deleteCacheButton]').click(); //Deleting cache aCache

cy.contains('Cache aCache deleted.');
cy.get('.pf-v5-c-alert__action > .pf-v5-c-button').click(); //Closing alert popup.
cy.get('aCache').should('not.exist'); //Checking that deleted cache is not visible
cy.contains('Cache default is now visible.').should('exist');
cy.get('[data-cy=ignoreBadge-default]').should('not.exist');
});

// Displays templates page
Expand Down
40 changes: 20 additions & 20 deletions cypress/e2e/rbac_func.cy.js → cypress/e2e/3_rbac_func.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('RBAC Functionlity Tests', () => {
cy.login(monitorUserName, Cypress.env('password'));
checkDataContainerView(true, false, false, false);
checkSecuredCacheDetailsView(true, false, false, 'monitor', 'indexed-cache');
checkNotOwnSecuredCache('super-cache');
checkNotOwnSecuredCache('a-rbac-test-cache');
checkNonSecuredCacheDetailView(true, false);
});

Expand All @@ -26,7 +26,7 @@ describe('RBAC Functionlity Tests', () => {
cy.contains('1 - 1 of 1');
cy.contains('Elaia');

checkNotOwnSecuredCache('super-cache');
checkNotOwnSecuredCache('a-rbac-test-cache');
checkNonSecuredCacheDetailView(false, false);
//Go to tasks (@TODO at the moment for observer no tasks are shown, add after fix)
checkSchemasPageView(false);
Expand All @@ -37,7 +37,7 @@ describe('RBAC Functionlity Tests', () => {
cy.login(applicationUserName, Cypress.env('password'));

checkDataContainerView(false, false, false, false);
checkSecuredCacheDetailsView(false, true, false, 'application', 'super-cache');
checkSecuredCacheDetailsView(false, true, false, 'application', 'a-rbac-test-cache');
checkActionsOnSuperCache();

checkNotOwnSecuredCache('indexed-cache');
Expand All @@ -51,7 +51,7 @@ describe('RBAC Functionlity Tests', () => {
cy.login(deployerUserName, Cypress.env('password'));

checkDataContainerView(false, true, true, false);
checkSecuredCacheDetailsView(false, true, false, 'deployer', 'super-cache');
checkSecuredCacheDetailsView(false, true, false, 'deployer', 'a-rbac-test-cache');
checkActionsOnSuperCache();

checkNotOwnSecuredCache('indexed-cache');
Expand All @@ -65,7 +65,7 @@ describe('RBAC Functionlity Tests', () => {
cy.login(Cypress.env('username'), Cypress.env('password'));

checkDataContainerView(false, true, true, true);
checkSecuredCacheDetailsView(false, true, true, 'admin', 'super-cache');
checkSecuredCacheDetailsView(false, true, true, 'admin', 'a-rbac-test-cache');
checkActionsOnSuperCache();

checkNotOwnSecuredCache('text-cache');
Expand All @@ -90,13 +90,13 @@ describe('RBAC Functionlity Tests', () => {
cy.get('[data-cy=cacheManagerStatus]').should('exist');
cy.get('[data-cy=navigationTabs]').should('exist');
cy.contains(/^\d+ Caches$/);
cy.contains('10 Counters');
cy.contains('Counters');
if (isMonitor) {
cy.contains('1 Tasks').should('not.exist');
cy.contains('13 Schemas').should('not.exist');
cy.contains('Tasks').should('not.exist');
cy.contains('Schemas').should('not.exist');
} else {
//cy.contains('1 Tasks'); //Should be uncommented after feature is implemented
cy.contains('13 Schemas');
cy.contains('Schemas');
}
cy.get('#cache-table-toolbar').should('exist');
cy.get('[data-cy=paginationArea]').should('exist');
Expand Down Expand Up @@ -140,8 +140,10 @@ describe('RBAC Functionlity Tests', () => {

if (isSuperAdmin) {
cy.get('#rebalancing-switch').should('exist');
cy.get('[data-cy=cacheConfigurationTab]').should('not.exist');
} else {
cy.get('#rebalancing-switch').should('not.exist');
cy.get('[data-cy=cacheConfigurationTab]').should('not.exist');
}

if (isMonitor) {
Expand All @@ -152,10 +154,6 @@ describe('RBAC Functionlity Tests', () => {
cy.get('[data-cy=queriesTab]').should('exist');
}

//Checking cache configuration page
cy.get('[data-cy=cacheConfigurationTab]').click();
cy.contains('authorization');
cy.contains(roleName);
cy.get('[data-cy=manageIndexesLink]').click();
if (isSuperAdmin) {
cy.get('[data-cy=clearIndexButton]').should('exist');
Expand Down Expand Up @@ -183,7 +181,7 @@ describe('RBAC Functionlity Tests', () => {
cy.contains('Data container').click();
cy.get('[id^="pagination-caches-top-pagination"]').first().click();
cy.get('[data-action=per-page-100]').click();
cy.contains(/cacheName$/).should('not.exist');
cy.contains('/' + cacheName +'$/').should('not.exist');
}

function checkNonSecuredCacheDetailView(isMonitor, isSuperAdmin) {
Expand Down Expand Up @@ -246,9 +244,11 @@ describe('RBAC Functionlity Tests', () => {
cy.get('[data-cy=clearAllButton]').click();
cy.get('[data-cy=deleteButton]').click();
cy.wait(1500); //Waiting till the whole page is loaded
//Checking cache configuration page
cy.get('[data-cy=cacheConfigurationTab]').click();
cy.contains('authorization').should('not.exist');
if (isSuperAdmin) {
//Checking cache configuration page
cy.get('[data-cy=cacheConfigurationTab]').click();
cy.contains('authorization').should('not.exist');
}
cy.get('[data-cy=manageIndexesLink]').click();
if (isSuperAdmin) {
cy.get('[data-cy=clearIndexButton]').should('exist');
Expand Down Expand Up @@ -314,7 +314,7 @@ describe('RBAC Functionlity Tests', () => {
parseSpecialCharSequences: false
});
cy.get('[data-cy=addButton]').click();
cy.contains('Entry added to cache super-cache.');
cy.contains('Entry added to cache a-rbac-test-cache.');
cy.get('[data-cy=actions-fordCar]').should('exist');
//Adding one more entry
cy.get('[data-cy=addEntryButton]').click();
Expand All @@ -327,7 +327,7 @@ describe('RBAC Functionlity Tests', () => {
parseSpecialCharSequences: false
});
cy.get('[data-cy=addButton]').click();
cy.contains('Entry added to cache super-cache.');
cy.contains('Entry added to cache a-rbac-test-cache.');
cy.get('[data-cy=actions-kiaCar]').should('exist');
//Editing entry
cy.get('[data-cy=actions-kiaCar] > button').click();
Expand All @@ -339,7 +339,7 @@ describe('RBAC Functionlity Tests', () => {
parseSpecialCharSequences: false
});
cy.get('[data-cy=addButton]').click();
cy.contains('Entry updated in cache super-cache.');
cy.contains('Entry updated in cache a-rbac-test-cache.');
cy.contains('2016');
//Deleting entry
cy.get('[data-cy=actions-kiaCar] > button').click();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 84e3ef1

Please sign in to comment.