Best JavaScript code snippet using cypress
RequestAccessList.js
Source:RequestAccessList.js
1Ext.ns('SailPoint', 'SailPoint.LCM', 'SailPoint.LCM.RequestAccess');2SailPoint.LCM.RequestAccess.vRadio = new SailPoint.VirtualRadioButton('requestAccessGrid','roleAction');3SailPoint.LCM.RequestAccess.identityId = null;4SailPoint.LCM.RequestAccess.roleId = null;5SailPoint.LCM.RequestAccess.assignableTypes = null;6SailPoint.LCM.RequestAccess.currentRequests = null;7SailPoint.LCM.RequestAccess.recordCache = {};8/** Constants **/9SailPoint.LCM.RequestAccess.STATUS_KEY = "IIQ_status";10SailPoint.LCM.RequestAccess.RADIO_CLASS = "revokeAccountRadio";11SailPoint.LCM.RequestAccess.PAGE_SIZE = 10;12SailPoint.LCM.RequestAccess.OBJECT_TYPE_ROLE = "role";13SailPoint.LCM.RequestAccess.OBJECT_TYPE_ENTITLEMENT = "entitlement";14SailPoint.LCM.RequestAccess.RequestedObjectStatus = {15 ADD_TO_CART: 'ADD_TO_CART',16 PROMPT_ACCOUNT_SELECTION: 'PROMPT_ACCOUNT_SELECTION',17 PROMPT_PERMITTED_ROLES: 'PROMPT_PERMITTED_ROLES',18 PENDING_REQUEST: 'PENDING_REQUEST',19 CURRENTLY_ASSIGNED: 'CURRENTLY_ASSIGNED',20 INVALID_REQUESTEES: 'INVALID_REQUESTEES',21 PROMPT_ACCOUNT_SELECTION_ROLE: 'PROMPT_ACCOUNT_SELECTION_ROLE',22 HAS_EXISTING_ASSIGNMENT: 'HAS_EXISTING_ASSIGNMENT',23 UNIQUE_ASSIGNMENT: 'UNIQUE_ASSIGNMENT',24 PROMPT_ROLE_ASSIGNMENT_SELECTION: 'PROMPT_ROLE_ASSIGNMENT_SELECTION'25};26Ext.define('SailPoint.LCM.RequestAccessList', {27 extend : 'Ext.tab.Panel',28 alias : 'widget.sprequestaccesslist',29 30 statics : {31 buttonClick : function(btn, event, eOpts) {32 Ext.MessageBox.wait('#{msgs.loading_data}'); 33 var account_request = SailPoint.LCM.RequestAccess.createAccountRequestFromRecord(SailPoint.LCM.RequestAccess.ATTRIBUTE_OP_ADD, btn.record, SailPoint.LCM.RequestAccess.OBJECT_TYPE);34 Ext.getCmp('requestAccessList').preAddRequest(account_request);35 }36 },37 store: null,38 hideMsgBox: true,39 40 /** Accepts all of the values on all of the fields and builds a filter to be passed41 * to the rest resource for filtering our results42 */43 filters: {},44 /** Current page of store **/45 page: 1,46 attributeMap: null,47 /** Role Configurable Properties **/48 allowPermitted : false, 49 allowAssignable : false,50 allowRoles : false,51 allowEntitlements : false,52 resultDetailsOptInEnabled: false,53 searchMaxResults: null,54 roleResultsProperties: [],55 entitlementResultsProperties: [],56 permittedRolesWin : null,57 permittedRolesGrid : null,58 currentAccessGrid : null,59 roleTpl : null,60 entitlementTpl : null, 61 constructor : function(config) {62 SailPoint.LCM.RequestAccess.assignableTypes = config.assignableTypes;63 if(config.allowRoles) {64 SailPoint.LCM.RequestAccess.OBJECT_TYPE = SailPoint.LCM.RequestAccess.OBJECT_TYPE_ROLE;65 } else if(config.allowEntitlements) {66 SailPoint.LCM.RequestAccess.OBJECT_TYPE = SailPoint.LCM.RequestAccess.OBJECT_TYPE_ENTITLEMENT;67 }68 this.resultDetailsOptInEnabled = config.resultDetailsOptInEnabled;69 this.roleResultsProperties = config.roleResultsProperties;70 this.entitlementResultsProperties = config.entitlementResultsProperties;71 this.store = this.createStore(config);72 this.items = [];73 // Horrible hack to fix the wrong width calculation of these panels in 74 // IE9. Only way I could figure out how to fix it. Please change if you 75 // find a better way.76 var listeners = {};77 if (Ext.isIE9) {78 listeners.afterlayout = {79 fn: function() {80 var IE9_OFFSET = 35;81 var panelIds = ['requestAccessRoleTab', 'requestAccessEntitlementTab'];82 var hasVerticalScrollbar = function(el) {83 return el.clientHeight < el.scrollHeight;84 };85 panelIds.each(function(id) {86 var panel = Ext.getCmp(id);87 if (panel && panel.getEl() && hasVerticalScrollbar(panel.getEl().dom)) {88 panel.getEl().setWidth(panel.getEl().getWidth() + IE9_OFFSET);89 }90 });91 }92 };93 }94 // Roles95 if(config.allowRoles) {96 var roleList = {97 xtype: 'dataview',98 id: 'requestAccessRoleTab',99 deferEmptyText: false,100 region:'center',101 autoScroll: true,102 itemSelector: 'div.request_item',103 emptyText: '#{msgs.lcm_request_access_no_items}',104 store: this.store,105 objectType: SailPoint.LCM.RequestAccess.OBJECT_TYPE_ROLE,106 tpl: this.getRoleTpl(),107 style: 'padding: 10px 5px',108 prepareData: this.prepareData109 };110 this.items.push({111 xtype:'panel',112 title: '#{msgs.roles}',113 id:'rolePanel',114 objectType: SailPoint.LCM.RequestAccess.OBJECT_TYPE_ROLE,115 layout: 'border',116 items: [{117 xtype:'sprequestaccessrolefilterpanel',118 attributeMap: config.attributeMap,119 region:'north',120 id : 'roleFilterForm',121 parent:this,122 collapsible:true,123 collapsed:true,124 collapseMode: 'mini',125 title:"#{msgs.lcm_request_access_filter_panel_title}",126 roleTypes: config.roleTypes,127 ruleData: config.ruleData128 },129 roleList130 ],131 listeners: listeners132 });133 }134 135 // Entitlements136 if(config.allowEntitlements) {137 var entitlementList = {138 xtype: 'dataview',139 id: 'requestAccessEntitlementTab',140 title: '#{msgs.entitlements}',141 deferEmptyText: false,142 itemSelector: 'div.request_item',143 emptyText: '#{msgs.lcm_request_access_no_items}',144 store: this.store,145 autoScroll: true,146 style: 'padding: 10px 5px',147 objectType: SailPoint.LCM.RequestAccess.OBJECT_TYPE_ENTITLEMENT,148 tpl: this.getEntitlementTpl(),149 prepareData: this.prepareData,150 section: 'south'151 };152 var filterPanel = {153 region:'north',154 autoScroll: true,155 parent: this,156 xtype:'sprequestaccessentitlementfilterpanel',157 attributeMap: config.attributeMap,158 ruleData: config.ruleData,159 id : 'entitlementFilterForm',160 collapsible:true,161 collapseMode: 'mini',162 collapsed:true,163 split: true, // bug #21023 part deux - adding splitter to give user more control of visible filter panel height164 title:"#{msgs.lcm_request_access_filter_panel_title}"165 };166 /* The filter panel expands and runs off the screen easily on the167 * iPad the proper fix is probably a more wide sweeping reevaluation168 * of viewport usage -jw169 * Bug #21023: limit height of search panel when viewable area is below supported resolution.170 */171 if(SailPoint.Platform.isMobile() || SailPoint.getBrowserViewArea().height <= SailPoint.minSupportedHeight) {172 filterPanel.height = 150;173 }174 else {175 // Bug #21023 part deux - when the viewable area is above the supported resolution we176 // need to limit the filter panel height otherwise when there are lots of searchable 177 // entitlement attributes it's possible the height can exceed the viewable area height.178 filterPanel.height = 300;179 }180 this.items.push({181 xtype:'panel',182 title: '#{msgs.entitlements}',183 id:'entitlementPanel',184 objectType: SailPoint.LCM.RequestAccess.OBJECT_TYPE_ENTITLEMENT,185 layout: 'border',186 items: [187 filterPanel,188 entitlementList189 ],190 listeners: listeners191 });192 }193 // Current Requests194 if(SailPoint.LCM.RequestAccess.identityId) {195 this.currentAccessGrid = new SailPoint.LCM.RequestAccessCurrentAccessGrid({196 id: 'requestAccessCurrentAccessGrid',197 currentIdentity: SailPoint.LCM.RequestAccess.identityId,198 gridMetaData: assignedGridMetaData,199 title: '#{msgs.lcm_current_access}',200 autoScroll: true,201 pageSize: config.pageSize,202 stateId: CURRENT_ACCESS_GRID_STATE_ID,203 stateful: true204 });205 this.items.push(this.currentAccessGrid);206 }207 this.callParent(arguments);208 },209 initComponent : function(){210 Ext.apply(this, {211 deferEmptyText: false,212 itemSelector: 'div.request_item',213 emptyText: '#{msgs.lcm_request_access_no_items}',214 plain: true,215 dockedItems: [{216 xtype: 'toolbar',217 id: 'requestAccessListTbar',218 dock: 'top',219 hidden: (!this.allowRoles && !this.allowEntitlements),220 items: [{221 xtype: 'button',222 text: "#{msgs.button_narrow_results}",223 scale : 'medium',224 id:'filterSearchResultsBtn',225 identityPanel: this,226 dock: 'top',227 handler: function(button) {228 if(SailPoint.LCM.RequestAccess.OBJECT_TYPE === SailPoint.LCM.RequestAccess.OBJECT_TYPE_ROLE) {229 Ext.getCmp('roleFilterForm').toggleCollapse();230 }231 else if(SailPoint.LCM.RequestAccess.OBJECT_TYPE === SailPoint.LCM.RequestAccess.OBJECT_TYPE_ENTITLEMENT) {232 Ext.getCmp('entitlementFilterForm').toggleCollapse();233 }234 }235 }, '->', {236 xtype: 'pagingtoolbar',237 id: 'pagingtoolbar',238 store: this.store, // same store GridPanel is using239 displayInfo: true240 }]241 }]242 }); 243 /** The filter panel that allows us to filter and sort the grid--defined 244 * in RequestAccessFilterPanel.js. Includes a typeTabPanel245 */246 this.on('beforetabchange', function(tabPanel, newItem, oldItem) {247 this.changeType(newItem.objectType);248 }, this);249 if(this.filterPanel) { 250 this.on('afterrender', function() {251 this.store.load();252 }, this);253 }254 this.callParent();255 },256 checkForErrors: function(store) {257 var errors = store.getErrors();258 if (errors && (errors.length > 0)) {259 Ext.Msg.show({260 title: '#{msgs.lcm_request_entitlements_identity_search_too_many_results_title}',261 msg: errors.join('. '),262 buttons: Ext.Msg.OK,263 icon: Ext.MessageBox.INFO264 });265 store.removeAll();266 }267 },268 prepareData: function(data, recordIndex, record) {269 var percent = Math.round((data.IIQ_population/data.IIQ_population_total)*100);270 var width = 100;271 var completeClass = "progressBarCompleteRed";272 273 if(percent >= 80) {274 completeClass = "progressBarCompleteGreen";275 } else if(percent >= 30 && percent < 80) {276 completeClass = "progressBarCompleteYellow";277 }278 279 var percentWidth = (percent / 100) * width;280 var remainingWidth = width - percentWidth;281 data.percent = percent;282 data.progressBarClass = completeClass;283 data.width = width;284 data.percentWidth = percentWidth;285 data.remainingWidth = remainingWidth;286 var warningContainer = Ext.get('requestAccessIdentityHighRiskWarning');287 if(warningContainer) {288 if(record.get('IIQ_has_high_risk')) {289 warningContainer.dom.style.display = '';290 } else {291 warningContainer.dom.style.display = 'none'; 292 }293 }294 warningContainer = Ext.get('requestAccessPopulationHighRiskWarning');295 if(warningContainer) {296 if(record.get('IIQ_has_high_risk')) {297 warningContainer.dom.style.display = '';298 } else {299 warningContainer.dom.style.display = 'none'; 300 }301 }302 return data;303 },304 injectButtons: function(records) {305 if(Ext.isArray(records)) {306 records.each(function(record) {307 var renderTo = SailPoint.LCM.RequestAccess.OBJECT_TYPE + '_button_' + record.getId();308 var inCart = record.get('IIQ_Selected') === true;309 310 var button = new Ext.Button({311 id: renderTo + '_btn',312 renderTo : renderTo,313 record: record,314 text : '#{msgs.lcm_add_to_cart}',315 hidden: inCart316 });317 318 // use managed listener for button clicks319 button.mon(button, 'click', SailPoint.LCM.RequestAccessList.buttonClick);320 321 });322 }323 },324 getRoleTpl : function() {325 if(!this.roleTpl) {326 this.roleTpl = Ext.create('SailPoint.LCM.RequestAccess.ResultTemplate', {327 type: 'role',328 optInEnabled: this.resultDetailsOptInEnabled,329 properties: this.roleResultsProperties330 });331 }332 return this.roleTpl;333 },334 getEntitlementTpl : function() {335 if(!this.entitlementTpl) {336 this.entitlementTpl = Ext.create('SailPoint.LCM.RequestAccess.ResultTemplate', {337 type: 'entitlement',338 optInEnabled: this.resultDetailsOptInEnabled,339 properties: this.entitlementResultsProperties340 });341 }342 return this.entitlementTpl;343 },344 changeType: function(type) {345 if(type) {346 SailPoint.LCM.RequestAccess.OBJECT_TYPE = type;347 Ext.getCmp('requestAccessListTbar').show();348 this.store.proxy.extraParams.type = type;349 this.store.defaultParams.type = type;350 this.store.sorters.clear();351 this.store.sorters.add({352 property: 'displayableName',353 direction: 'ASC'354 });355 this.store.loadPage(1);356 this.page = 1;357 } else {358 Ext.getCmp('requestAccessListTbar').hide();359 }360 },361 getSortPropertyForType: function(type) {362 if (type === SailPoint.LCM.RequestAccess.OBJECT_TYPE_ROLE) {363 return 'displayableName';364 }365 return 'name';366 },367 createStore: function(config) {368 this.store = SailPoint.Store.createRestStore({369 fields : config.listStoreFields,370 autoLoad : false,371 pageSize: SailPoint.LCM.RequestAccess.PAGE_SIZE,372 url : SailPoint.getRelativeUrl('/rest/requestAccess/grid'),373 extraParams : {374 'allowPermitted' : config.allowPermitted,375 'allowAssignable' : config.allowAssignable,376 'lcm' : true,377 'identityId': config.currentIdentity,378 'type' : SailPoint.LCM.RequestAccess.OBJECT_TYPE379 },380 /** The default params are a bag of params that we keep on the store to apply to 381 * every search since we mess with the extraParams so much. We keep them around so we can382 * always apply them back to the store once the user has hit "clear filters"383 */384 defaultParams : {385 'allowPermitted' : config.allowPermitted,386 'allowAssignable' : config.allowAssignable,387 'lcm' : true,388 'identityId': config.currentIdentity,389 'type' : SailPoint.LCM.RequestAccess.OBJECT_TYPE,390 'sort' : 'displayableName'391 },392 sorters : [{393 property : 'displayableName',394 direction : 'ASC'395 }],396 remoteSort : true397 });398 this.store.on('load', function(store, records, isSuccessful, operation, options) {399 this.checkForErrors(store);400 this.injectButtons(records); 401 this.updateTabCounts(store.getProxy().getReader().rawData);402 }, this);403 return this.store;404 },405 updateTabCounts: function(response) {406 var roleCount = response.count;407 var entitlementCount = response.inactiveCount;408 if (this.isEntitlementsTabActive()) {409 roleCount = response.inactiveCount;410 entitlementCount = response.count;411 }412 this.updateRoleTabCount(roleCount);413 this.updateEntitlementTabCount(entitlementCount);414 },415 updateRoleTabCount: function(count) {416 var roleTab = Ext.getCmp('rolePanel');417 if (roleTab) {418 roleTab.setTitle('#{msgs.roles} (' + this.formatCount(count) + ')');419 }420 },421 updateEntitlementTabCount: function(count) {422 var entitlementsTab = Ext.getCmp('entitlementPanel');423 if (entitlementsTab) {424 entitlementsTab.setTitle('#{msgs.entitlements} (' + this.formatCount(count) + ')');425 }426 },427 formatCount: function(count) {428 if (count >= this.searchMaxResults) {429 return this.searchMaxResults + '+';430 }431 return count;432 },433 isRolesTabActive: function() {434 return SailPoint.LCM.RequestAccess.OBJECT_TYPE === SailPoint.LCM.RequestAccess.OBJECT_TYPE_ROLE;435 },436 isEntitlementsTabActive: function() {437 return SailPoint.LCM.RequestAccess.OBJECT_TYPE === SailPoint.LCM.RequestAccess.OBJECT_TYPE_ENTITLEMENT;438 },439 preAddRequest : function(account_request) {440 var requests = [];441 requests.push(account_request);442 443 Ext.Ajax.request({444 method: 'POST',445 url: SailPoint.getRelativeUrl('/rest/requestAccess/additionalQuestions'),446 success: function(response) {447 var data = Ext.JSON.decode(response.responseText);448 var dataStatus = data.status;449 this.hideMsgBox = Boolean(dataStatus==SailPoint.LCM.RequestAccess.RequestedObjectStatus.ADD_TO_CART ||450 dataStatus==SailPoint.LCM.RequestAccess.RequestedObjectStatus.PROMPT_PERMITTED_ROLES ||451 dataStatus==SailPoint.LCM.RequestAccess.RequestedObjectStatus.PROMPT_ACCOUNT_SELECTION_ROLE ||452 dataStatus==SailPoint.LCM.RequestAccess.RequestedObjectStatus.PROMPT_ROLE_ASSIGNMENT_SELECTION);453 454 switch(dataStatus) {455 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.ADD_TO_CART:456 this.addToCart(account_request, data);457 break;458 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.PROMPT_PERMITTED_ROLES:459 account_request.arguments.updateable = "true"; 460 this.promptPermittedRole(account_request, data, dataStatus); 461 break;462 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.PROMPT_ACCOUNT_SELECTION:463 account_request.arguments.updateable = "true";464 this.promptAccountChoice(account_request, data.actionType, data.hasInstances, data.requesteeNameMap, data.requesteeActionMap);465 break;466 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.PENDING_REQUEST:467 Ext.Msg.alert('#{msgs.lcm_request_access_unable_add_cart_title}', '#{msgs.lcm_request_access_pending_request}');468 break;469 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.CURRENTLY_ASSIGNED:470 Ext.Msg.alert('#{msgs.lcm_request_access_unable_add_cart_title}', '#{msgs.lcm_request_access_currently_assigned}');471 break;472 473 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.INVALID_REQUESTEES:474 var message = Ext.String.format('#{msgs.lcm_request_err_invalid_requestees}', data.invalidObject, data.invalidRequestees);475 Ext.Msg.alert('#{msgs.lcm_request_err_invalid_requestees_title}', message);476 break;477 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.PROMPT_ACCOUNT_SELECTION_ROLE:478 this.promptRoleAccountSelection(account_request, data, dataStatus);479 break;480 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.PROMPT_ROLE_ASSIGNMENT_SELECTION:481 this.promptRoleAssignmentSelection(account_request, data, dataStatus);482 break;483 }484 },485 callback : function() {486 var hide = this.hideMsgBox;487 if(hide)488 Ext.MessageBox.hide();489 },490 params: {'request': Ext.JSON.encode(requests), 'identityId': SailPoint.LCM.RequestAccess.identityId, 'allowPermitted' : this.allowPermitted},491 scope: this492 });493 },494 addToCart: function(accountRequest, data) {495 // add assignment id to attribute request if exists, currently this is only496 // for direct permitted role requests497 if (!Ext.isEmpty(data.assignmentId)) {498 accountRequest.attributeRequests[0].assignmentId = data.assignmentId;499 }500 Ext.getCmp('requestAccessList').addRequest(accountRequest);501 },502 showItemInCart: function(stub) {503 var btn = Ext.getCmp(stub.getButtonCmpId());504 if (btn) {505 btn.hide();506 }507 508 var inCartEl = Ext.get(stub.getInCartId());509 if (inCartEl) {510 inCartEl.setStyle('display', 'inline');511 }512 },513 hasExistingAssignment : function(requests, accountInfos, popup) {514 popup.enableButtons(false);515 516 //Get the account info objects out of the account request arguments 517 // and put the JSON on the page.518 if (Ext.isEmpty(accountInfos)) {519 var accountInfos = [];520 for (i=0; i<requests.length; i++) {521 request = requests[i];522 if (request.arguments.accountInfos) {523 accountInfos.push.apply(accountInfos, request.arguments.accountInfos);524 request.arguments.accountInfos = null;525 }526 }527 }528 var hasExistingAssignment = false;529 var requestsJSON = Ext.JSON.encode(requests);530 var accountInfosJSON = Ext.JSON.encode(accountInfos);531 Ext.Ajax.request({532 method: 'POST',533 async: false,534 url: SailPoint.getRelativeUrl('/rest/requestAccess/checkUniqueAssignment'),535 success: function(response) {536 var data = Ext.JSON.decode(response.responseText);537 var dataStatus = data.status;538 539 switch(dataStatus) {540 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.UNIQUE_ASSIGNMENT:541 hasExistingAssignment = false;542 break;543 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.HAS_EXISTING_ASSIGNMENT:544 popup.enableButtons(true);545 Ext.Msg.show( {546 title: '#{msgs.lcm_request_err_existing_assignment_title}',547 msg: data.errorMessage,548 buttons: Ext.Msg.OK,549 icon: Ext.MessageBox.ERROR550 } );551 hasExistingAssignment = true;552 break;553 }554 },555 params: {'requests': requestsJSON, 'accountInfos': accountInfosJSON},556 scope: this557 });558 559 return hasExistingAssignment;560 },561 addRequests : function(requests, accountInfos) {562 var me = this;563 var stubs = SailPoint.LCM.RequestAccess.createRequestStubs(requests);564 stubs.each(function(stub) {565 var btn = Ext.getCmp(stub.getButtonCmpId());566 if (btn) {567 btn.setDisabled(true);568 }569 });570 Page.on('cartItemsAdded', function() {571 stubs.each(function(stub) {572 me.showItemInCart(stub);573 var record = me.store.getById(stub.id);574 if (record) {575 record.set('IIQ_Selected', true);576 }577 });578 }, null, { single: true });579 Page.on('addCartItemsError', function() {580 stubs.each(function(stub) {581 var btn = Ext.getCmp(stub.getButtonCmpId());582 if (btn) {583 btn.setDisabled(false);584 }585 });586 }, null, { single: true });587 588 //Get the account info objects out of the account request arguments 589 // and put the JSON on the page.590 if (Ext.isEmpty(accountInfos)) {591 var accountInfos = [];592 for (i=0; i<requests.length; i++) {593 request = requests[i];594 if (request.arguments.accountInfos) {595 accountInfos.push.apply(accountInfos, request.arguments.accountInfos);596 request.arguments.accountInfos = null;597 }598 }599 }600 $('editForm:requestsJSON').value = Ext.JSON.encode(requests);601 $('editForm:accountInfosJSON').value = Ext.JSON.encode(accountInfos);602 $('editForm:addRequestBtn').click();603 $('editForm:requestsJSON').value = '[]';604 $('editForm:accountInfosJSON').value = '[]';605 },606 addRequest : function (account_request) {607 var requests = [];608 requests.push(account_request); 609 this.addRequests(requests);610 },611 promptPermittedRole : function(accountRequest, data, status) {612 var roleWizard = Ext.create('SailPoint.LCM.RequestAccessRoleWizard', {613 accountRequest: accountRequest,614 gridMetaData: this.gridMetaData,615 requestAccessList: this,616 allowAssignmentNote: data.isAssignable,617 status: status618 });619 roleWizard.show();620 },621 promptRoleAssignmentSelection: function(accountRequest, data, status) {622 var roleWizard = Ext.create('SailPoint.LCM.RequestAccessRoleWizard', {623 accountRequest: accountRequest,624 gridMetaData: this.gridMetaData,625 requestAccessList: this,626 allowAssignmentNote: data.isAssignable,627 identityId: SailPoint.LCM.RequestAccess.identityId,628 status: status629 });630 roleWizard.show();631 },632 promptRoleAccountSelection: function(accountRequest, data, status) {633 var roleWizard = Ext.create('SailPoint.LCM.RequestAccessRoleWizard', {634 accountSelections: data.requesteeSelections,635 accountRequest: accountRequest,636 gridMetaData: this.gridMetaData,637 requestAccessList: this,638 allowAssignmentNote: data.isAssignable,639 status: status,640 assignmentId: data.assignmentId641 });642 roleWizard.show();643 },644 promptAccountChoice : function(account_request, action_type, hasInstances, requesteeNameMap, requesteeActionMap) {645 if (this.accountChoiceWindow) {646 //If this is for a different application than the last time we used the 647 //account choice window, destroy it and make a new one. Otherwise, update the 648 //window for new account request.649 if (account_request.application !== this.accountChoiceWindow.getApplication()) {650 this.accountChoiceWindow.destroy();651 this.accountChoiceWindow = null;652 } else {653 this.accountChoiceWindow.setAccountRequest(account_request);654 }655 }656 657 if (!this.accountChoiceWindow) {658 this.accountChoiceWindow = new SailPoint.LCM.RequestAccessAccountChoiceWindow({659 account_request : account_request,660 closeAction: 'hide',661 modal:true,662 action_type: action_type,663 closable: true,664 hasInstances: hasInstances,665 identityMap: requesteeNameMap,666 actionMap: requesteeActionMap667 });668 }669 670 this.accountChoiceWindow.show();671 },672 clearFilters: function() {673 this.filters = {};674 },675 /** Takes the built filter and applies it to the store of the grid that is associated with the filter panel **/676 runSearch : function(filters) { 677 if(filters) {678 this.filters = filters;679 }680 var searchField = Ext.getCmp('searchField');681 if(!searchField.isDisabled()) {682 this.filters['query'] = searchField.getValue(); 683 } else { 684 delete this.filters.query;685 }686 /** Reset the store params using the defaultParams that we init'd the store with **/687 this.store.proxy.extraParams = {};688 /** Set the default parameters like type, showPermitted, etc... **/689 for (var attrname in this.store.defaultParams) { 690 if(this.store.defaultParams.hasOwnProperty(attrname)) { 691 this.store.proxy.extraParams[attrname] = this.store.defaultParams[attrname]; 692 }693 }694 for (var attrname in this.filters) { 695 /** Skip inherited properties such as functions **/696 if(this.filters.hasOwnProperty(attrname)) {697 this.store.proxy.extraParams[attrname] = this.filters[attrname];698 }699 }700 this.store.loadPage(1);701 }702});703Ext.define('SailPoint.LCM.RequestAccess.ResultTemplate', {704 extend: 'Ext.XTemplate',705 statics: {706 MAX_DESC_CHARS: 270707 },708 type: null,709 optInEnabled: false,710 properties: [],711 staticProperties: ['name', 'displayableName', 'description'],712 constructor: function(config) {713 var me = this;714 config = config || {};715 716 Ext.applyIf(config, {717 properties: []718 });719 var header = [720 '<tpl for=".">',721 '<tpl if="this.isRole()">',722 '<div class="request_item {IIQ_icon} {IIQ_icon}Large">',723 '<tpl else>',724 '<div class="request_item {application-icon}Large">',725 '</tpl>',726 '<tpl if="IIQ_population">',727 '<div class="progressBarContainer" onclick="populationWindow.showIdentities(\'{[this.getPopulationIdParam()]}\', \'{id}\', \'{name}\');">',728 '<span class="progressBarNumComplete">',729 '<span class="progressBarTotal">{percent}% ({IIQ_population}/{IIQ_population_total}) <img class="progressDisclosure" src="'730 + SailPoint.getRelativeUrl('/images/icons/general_disclosure_arrow_10.png') + '"/>',731 '</span>',732 '</span>',733 '<div class="progressBar short" style="width: {width}px;">',734 '<span class="{progressBarClass}" style="width: {percentWidth}px; left: 1px;"></span>',735 '<span class="progressBarRemainingDarkGray" style="width: {remainingWidth}px; left: {percentWidth}px;"></span>',736 '</div>',737 '</div>',738 '</tpl>',739 '<div class="lcmNameTitle">',740 '<tpl if="this.isRole()">',741 '<a href="javascript:SailPoint.RoleDetailPanel.window(null, \'{id}\', \'{identityId}\', true)" title="#{msgs.info_role_composition}">',742 '{[Ext.String.htmlEncode(values.displayableName)]} {identityId}',743 '</a>',744 '<tpl else>',745 '{name}',746 '</tpl>',747 '</div>',748 '<tpl if="this.isOptInEnabled()">',749 '<span id="trunc_desc_{[this.getType()]}_{id}" class="description">{[this.getTruncatedDescription(values.description)]}</span>',750 '<div id="result_details_{[this.getType()]}_{id}" style="display: none;">',751 '</tpl>',752 '<span class="description">{description}</span>',753 '<div class="properties">'754 ];755 var properties = [];756 config.properties.each(function(property) {757 if (me.isInvalidProperty(property)) {758 return true;759 }760 if (me.hasRenderer(property)) {761 property.renderer = SailPoint.evaluteFunctionByName(property.renderer, window);762 }763 properties.push(me.renderPropertyTemplate(property));764 });765 var footer = [766 '</div>',767 '<tpl if="this.isOptInEnabled()">',768 '</div>',769 '<div class="request-access-view-details">',770 '<a href="#" class="show-details" onclick="SailPoint.LCM.RequestAccess.toggleDetails(this, \'{id}\', \'{[this.getType()]}\'); return false;">',771 '#{msgs.lcm_request_access_view_details}',772 '</a>',773 '</div>',774 '</tpl>',775 '<div class="buttonHolder">',776 '<span class="in-cart" id="{[this.getType()]}_button_{id}_incart" style="display: {[values.IIQ_Selected === true ? "inline" : "none"]};">',777 '#{msgs.lcm_in_cart}',778 '</span>',779 '<span id="{[this.getType()]}_button_{id}"></span>',780 '</div>',781 '</div>',782 '</tpl>'783 ];784 this.callParent([header.concat(properties, footer).join(''), config]);785 },786 isInvalidProperty: function(property) {787 return property.hidden === true || this.staticProperties.indexOf(property.dataIndex) >= 0;788 },789 hasRenderer: function(property) {790 return property.renderer && Ext.typeOf(property.renderer) === 'string' && property.renderer.length > 0;791 },792 renderPropertyTemplate: function(property) {793 var rendered = '';794 if (property.renderer) {795 rendered = property.renderer(property);796 } else {797 rendered = this.renderDefaultPropertyTemplate(property);798 }799 return Ext.String.format('<span class="property">{0}</span>', rendered);800 },801 renderDefaultPropertyTemplate: function(property) {802 return property.header + ': {[values["' + property.dataIndex + '"] === null ? "" : values["' + property.dataIndex + '"]]}';803 },804 getType: function() {805 return this.type;806 },807 isRole: function() {808 return this.getType() === 'role';809 },810 isEntitlement: function() {811 return this.getType() === 'entitlement';812 },813 getPopulationIdParam: function() {814 if (this.isEntitlement()) {815 return 'entitlementId';816 }817 return 'roleId';818 },819 isOptInEnabled: function() {820 return this.optInEnabled;821 },822 getTruncatedDescription: function(description) {823 if (!description) {824 return '';825 }826 var maxLength = this.getMaxDescriptionLength();827 if (description.length <= maxLength) {828 return description;829 }830 return description.substring(0, maxLength) + '...';831 },832 getMaxDescriptionLength: function() {833 return SailPoint.LCM.RequestAccess.ResultTemplate.MAX_DESC_CHARS;834 }835});836SailPoint.LCM.RequestAccess.createRequestStubs = function(requests) {837 var stubs = [];838 requests.each(function(request) {839 stubs.push({840 id: request.arguments.id,841 type: request.type,842 getButtonContainerId: function() {843 return this.type + '_button_' + this.id;844 },845 getButtonCmpId: function() {846 return this.getButtonContainerId() + '_btn';847 },848 getInCartId : function() {849 return this.getButtonContainerId() +'_incart';850 }851 });852 });853 return stubs;854};855SailPoint.LCM.RequestAccess.toggleDetails = function(el, id, type) {856 var element = Ext.get(el);857 var truncDescEl = $(Ext.String.format('trunc_desc_{0}_{1}', type, id));858 var detailsEl = $(Ext.String.format('result_details_{0}_{1}', type, id));859 if (element.hasCls('show-details')) {860 truncDescEl.hide();861 detailsEl.show();862 element.removeCls('show-details')863 .addCls('hide-details')864 .setHTML('#{msgs.lcm_request_access_hide_details}');865 } else {866 truncDescEl.show();867 detailsEl.hide();868 element.removeCls('hide-details')869 .addCls('show-details')870 .setHTML('#{msgs.lcm_request_access_view_details}');871 }872};873SailPoint.LCM.RequestAccess.loadPage = function(page) {874 var requestAccessList = Ext.getCmp('requestAccessList');875 requestAccessList.getStore().loadPage(page);876 requestAccessList.page = page;877};878SailPoint.LCM.RequestAccess.riskScoreRenderer = function(property) {879 return property.header + ': <div class="riskIndicator ri_{IIQ_color}">{riskScore}</div>';880};881Ext.define('SailPoint.LCM.RequestAccess.AccountInfo', {882 id: null,883 identityId: null,884 nativeIdentity: null,885 instance: null,886 887 constructor: function() {888 this.id = randomUUID();889 }...
RequestAccessAccountChoiceWindow.js
Source:RequestAccessAccountChoiceWindow.js
1SailPoint.LCM.RequestAccess.ACTION_CHOOSE_INSTANCE = 1;2SailPoint.LCM.RequestAccess.ACTION_CHOOSE_NATIVE_IDENTITY = 2;3SailPoint.LCM.RequestAccess.ACTION_CREATE_ACCOUNT = 3;4Ext.define('SailPoint.LCM.RequestAccessAccountChoiceWindow', {5 extend : 'Ext.window.Window',6 account_request: null,7 8 /** Panels **/9 formPanel : null,10 detailsPanel : null,11 12 /** Whether this is bulk request **/13 isBulk: false,14 15 constructor : function(config){16 17 Ext.apply(this, {18 account_request: config.account_request,19 hasInstances: config.hasInstances, 20 isBulk: (!SailPoint.LCM.RequestAccess.identityId || SailPoint.LCM.RequestAccess.identityId == "")21 });22 23 this.template = new Ext.XTemplate(24 '<tpl for=".">',25 '<p class="accountChoiceDetailsInstructions">#{msgs.lcm_request_access_account_instructions}</p>',26 '<div class="accountChoiceDetails">',27 '<table class="details">',28 '<tr><td><label>#{msgs.name}:</label></td><td class="pl">{arguments.displayableName}</td></tr>',29 '<tr><td><label>#{msgs.application}:</label></td><td class="pl">{application}</td></tr>',30 '<tr><td><label>#{msgs.owner}:</label></td><td class="pl">{arguments.owner}</td></tr>',31 '</table>',32 '</div>',33 '</tpl>');34 35 this.detailsPanel = Ext.create('Ext.panel.Panel', {36 height:125,37 bodyStyle: 'padding: 10px;',38 region: 'north',39 tpl: this.template,40 data: this.account_request41 });42 43 //For bulk requests, create a panel for each identity in config.identityMap44 var formItems = [];45 if (!this.isBulk) {46 var accountPanel = this.createSelectAccountPanel(SailPoint.LCM.RequestAccess.identityId, SailPoint.LCM.RequestAccess.identityName, config.action_type);47 formItems.push(accountPanel);48 } else if (config.identityMap) {49 for (var requesteeId in config.identityMap) {50 if (config.identityMap.hasOwnProperty(requesteeId)) {51 var accountPanel = this.createSelectAccountPanel(requesteeId, config.identityMap[requesteeId], config.actionMap[requesteeId]);52 formItems.push(accountPanel);53 }54 }55 }56 57 this.formPanel = Ext.create('Ext.form.Panel', {58 id: 'selectAccountFormPanel',59 region: 'center',60 defaults: {61 // applied to each contained panel62 padding: '0 0 5 0'63 },64 overflowY: 'auto',65 items: formItems66 });67 Ext.apply(config, {68 title: Ext.String.format("#{msgs.lcm_request_access_select_account_title}", config.account_request.arguments.displayableName),69 id: 'accountChoiceWindow',70 layout:'border',71 width:600,72 height:(formItems.length == 1) ? 300 : 400,73 items : [this.detailsPanel, this.formPanel],74 listeners: {75 close: function() {76 Ext.MessageBox.hide();77 }78 },79 buttons: [80 {81 text:'#{msgs.button_continue}',82 handler: function() {83 var window = Ext.getCmp('accountChoiceWindow');84 if(window.formPanel.getForm().isValid()) {85 var panels = window.formPanel.queryBy(function(component){86 return (component instanceof SailPoint.LCM.RequestAccessSelectAccountPanel);87 });88 89 if (panels != null && panels.length > 0) {90 for (i = 0; i < panels.length; i++) {91 window.updateAccountRequest(window.account_request, panels[i]);92 }93 }94 if (window.account_request.nativeIdentity === 'new' || window.isBulk) {95 // This is a request for a new account or a bulk request. 96 // We're done.97 Ext.getCmp('requestAccessList').addRequest(window.account_request);98 window.close();99 }100 else {101 // Well now we have to check their selection again. Now that102 // they've chosen an account to which to apply this entitlement,103 // we need to to check again and make sure that this new account104 // doesn't already have the entitlement.105 var requests = [];106 requests.push(window.account_request);107 108 Ext.Ajax.request({109 method: 'POST',110 url: SailPoint.getRelativeUrl('/rest/requestAccess/additionalQuestions'),111 success: function(response) {112 113 // decode the response114 var data = Ext.JSON.decode(response.responseText);115 var dataStatus = data.status;116 117 // Based on the response, what should we do?118 switch(dataStatus) {119 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.ADD_TO_CART:120 // This is what happens when the account selection is successful.121 // Add the request and close the dialog.122 Ext.getCmp('requestAccessList').addRequest(window.account_request);123 window.close();124 break;125 126 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.PROMPT_PERMITTED_ROLES:127 // Huh? Permitted roles? We're way off course if we end up here.128 // We're trying to find out to which account you want to apply the entitlement.129 break;130 131 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.PROMPT_ACCOUNT_SELECTION:132 // We're already here.133 break;134 135 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.PENDING_REQUEST:136 Ext.Msg.alert('#{msgs.lcm_request_access_unable_add_cart_title}', '#{msgs.lcm_request_access_pending_request}');137 break;138 139 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.CURRENTLY_ASSIGNED:140 Ext.Msg.alert('#{msgs.lcm_request_access_unable_add_cart_title}', '#{msgs.lcm_request_access_currently_assigned}');141 break;142 143 case SailPoint.LCM.RequestAccess.RequestedObjectStatus.INVALID_REQUESTEES:144 var message = Ext.String.format('#{msgs.lcm_request_err_invalid_requestees}', data.invalidObject, data.invalidRequestees);145 Ext.Msg.alert('#{msgs.lcm_request_err_invalid_requestees_title}', message);146 break;147 }148 },149 params: {'request': Ext.JSON.encode(requests),150 'identityId': SailPoint.LCM.RequestAccess.identityId,151 'allowPermitted': SailPoint.LCM.RequestAccess.allowPermitted},152 scope: this153 });154 }155 } 156 } 157 },158 {159 text:'#{msgs.button_cancel}', cls : 'secondaryBtn', window: this, handler: function() { Ext.getCmp('accountChoiceWindow').close(); }160 }161 ]162 });163 Ext.apply(this, config);164 165 this.callParent(arguments);166 },167 168 setAccountRequest: function(account_request) {169 this.account_request = account_request;170 this.setTitle(Ext.String.format("#{msgs.lcm_request_access_select_account_title}", account_request.arguments.displayableName));171 this.detailsPanel.update(this.account_request);172 },173 174 getApplication : function() {175 return (this.account_request) ? this.account_request.application : null;176 },177 178 createSelectAccountPanel : function(identityId, identityName, action_type) {179 return Ext.create('SailPoint.LCM.RequestAccessSelectAccountPanel',180 {181 action_type: action_type,182 identityId: identityId,183 identityName: identityName,184 account_request: this.account_request,185 hasInstances: this.hasInstances186 187 });188 },189 /**190 * Set the native identity nad instance information in the account request.191 * For bulk requests, create an account info object and store it in the 192 * arguments temporarily193 */194 updateAccountRequest : function(account_request, selectAccountPanel) {195 var nativeIdentity = selectAccountPanel.getNativeIdentity();196 if(nativeIdentity=='#{msgs.lcm_request_entitlements_create_account_option_desc}') {197 nativeIdentity = 'new';198 if (!this.isBulk) {199 account_request.operation = SailPoint.LCM.RequestAccess.MODIFY;200 }201 }202 203 var instance = selectAccountPanel.getInstance();204 if (this.isBulk) {205 var accountInfo = new SailPoint.LCM.RequestAccess.AccountInfo();206 accountInfo.identityId = selectAccountPanel.getIdentityId();207 accountInfo.nativeIdentity = nativeIdentity;208 accountInfo.instance = instance;209 if (!account_request.arguments.accountInfos) {210 account_request.arguments.accountInfos = [];211 account_request.arguments.accountInfoIds = accountInfo.id;212 } else {213 account_request.arguments.accountInfoIds = account_request.arguments.accountInfoIds + "," + accountInfo.id;214 }215 account_request.arguments.accountInfos.push(accountInfo);216 217 } else {218 account_request.nativeIdentity = nativeIdentity;219 account_request.instance = instance;220 }221 }222 ...
enable-command.test.js
Source:enable-command.test.js
1'use strict'2/* eslint-env browser, webextensions */3const browser = require('sinon-chrome')4const { describe, it, before, after } = require('mocha')5const { expect } = require('chai')6const { URL } = require('url')7const Storage = require('mem-storage-area/Storage')8const Sinon = require('sinon')9const AccessControl = require('../../../../add-on/src/lib/ipfs-proxy/access-control')10const createEnableCommand = require('../../../../add-on/src/lib/ipfs-proxy/enable-command')11const createRequestAccess = require('../../../../add-on/src/lib/ipfs-proxy/request-access')12const { initState } = require('../../../../add-on/src/lib/state')13const { optionDefaults } = require('../../../../add-on/src/lib/options')14describe('lib/ipfs-proxy/enable-command', () => {15 before(() => {16 global.URL = URL17 global.browser = browser18 global.screen = global.screen || { width: 1024, height: 720 }19 })20 it('should throw if proxy access is disabled globally', async () => {21 const getState = () => initState(optionDefaults, { ipfsProxy: false })22 const accessControl = new AccessControl(new Storage())23 const getScope = () => 'https://1.foo.tld/path/'24 const getIpfs = () => {}25 const requestAccess = createRequestAccess(browser, screen)26 const enable = createEnableCommand(getIpfs, getState, getScope, accessControl, requestAccess)27 const permissions = { commands: ['files.mkdir', 'id', 'version'] }28 let error29 try {30 await enable(permissions)31 } catch (err) {32 error = err33 }34 expect(() => { if (error) throw error }).to.throw('User disabled access to API proxy in IPFS Companion')35 expect(error.scope).to.equal(undefined)36 expect(error.permissions).to.be.equal(undefined)37 })38 it('should throw if ALL IPFS integrations are disabled for requested scope', async () => {39 const getState = () => initState(optionDefaults, {40 ipfsProxy: true,41 disabledOn: ['foo.tld']42 })43 const accessControl = new AccessControl(new Storage())44 const getScope = () => 'https://1.foo.tld/path/'45 const getIpfs = () => {}46 const requestAccess = createRequestAccess(browser, screen)47 const enable = createEnableCommand(getIpfs, getState, getScope, accessControl, requestAccess)48 const permissions = { commands: ['files.mkdir', 'id', 'version'] }49 let error50 try {51 await enable(permissions)52 } catch (err) {53 error = err54 }55 expect(() => { if (error) throw error }).to.throw('User disabled access to API proxy in IPFS Companion')56 expect(error.scope).to.equal(undefined)57 expect(error.permissions).to.be.equal(undefined)58 })59 it('should throw if access to unknown command is requested', async () => {60 const getState = () => initState(optionDefaults, { ipfsProxy: true })61 const accessControl = new AccessControl(new Storage())62 const getScope = () => 'https://2.foo.tld/path/'63 const getIpfs = () => {}64 const requestAccess = createRequestAccess(browser, screen)65 const enable = createEnableCommand(getIpfs, getState, getScope, accessControl, requestAccess)66 let error67 try {68 await enable({ commands: ['id', 'FAKECOMMAND'] })69 } catch (err) {70 error = err71 }72 expect(() => { if (error) throw error }).to.throw("Access to 'FAKECOMMAND' commands over IPFS Proxy is globally blocked")73 })74 it('should return without prompt if called without any arguments', async () => {75 const getState = () => initState(optionDefaults, { ipfsProxy: true })76 const accessControl = new AccessControl(new Storage())77 const getScope = () => 'https://3.foo.tld/path/'78 const getIpfs = () => {}79 const requestAccess = Sinon.spy(async () => { throw new Error('THIS SHOULD NOT HAPPEN ;-)') })80 const enable = createEnableCommand(getIpfs, getState, getScope, accessControl, requestAccess)81 // get IPFS API instance82 await enable()83 // confirm there was no user prompt84 expect(requestAccess.called).to.equal(false)85 })86 it('should request access if no grant exists', async () => {87 const getState = () => initState(optionDefaults, { ipfsProxy: true })88 const accessControl = new AccessControl(new Storage())89 const getScope = () => 'https://4.foo.tld/path/'90 const getIpfs = () => {}91 const requestAccess = Sinon.spy(async () => ({ allow: true }))92 const enable = createEnableCommand(getIpfs, getState, getScope, accessControl, requestAccess)93 const permissions = { commands: ['id', 'version'] }94 await enable(permissions)95 expect(requestAccess.called).to.equal(true)96 const { allow } = await accessControl.getAccess(getScope(), 'version')97 expect(allow).to.equal(true)98 })99 it('should request access if partial grant exists', async () => {100 const getState = () => initState(optionDefaults, { ipfsProxy: true })101 const accessControl = new AccessControl(new Storage())102 const getScope = () => 'https://4.foo.tld/path/'103 const getIpfs = () => {}104 const requestAccess = Sinon.spy(async () => ({ allow: true }))105 const enable = createEnableCommand(getIpfs, getState, getScope, accessControl, requestAccess)106 const permissions = { commands: ['id', 'version'] }107 // ensure partial grant exists108 await accessControl.setAccess(getScope(), 'id', true)109 const idAcl = await accessControl.getAccess(getScope(), 'id')110 expect(idAcl.allow).to.equal(true)111 await enable(permissions)112 expect(requestAccess.called).to.equal(true)113 const versionAcl = await accessControl.getAccess(getScope(), 'version')114 expect(versionAcl.allow).to.equal(true)115 })116 it('should deny access if any partial deny already exists', async () => {117 const getState = () => initState(optionDefaults, { ipfsProxy: true })118 const accessControl = new AccessControl(new Storage())119 const getScope = () => 'https://4.foo.tld/path/'120 const getIpfs = () => {}121 const requestAccess = Sinon.spy(async () => ({ allow: true }))122 const enable = createEnableCommand(getIpfs, getState, getScope, accessControl, requestAccess)123 const permissions = { commands: ['id', 'version'] }124 // ensure partial deny exists125 await accessControl.setAccess(getScope(), 'id', false)126 const idAcl = await accessControl.getAccess(getScope(), 'id')127 expect(idAcl.allow).to.equal(false)128 // main test129 let error130 try {131 await enable(permissions)132 } catch (err) {133 error = err134 }135 // confirm build permission request failed with error136 expect(requestAccess.called).to.equal(false)137 expect(() => { if (error) throw error }).to.throw('User denied access to selected commands over IPFS proxy: id')138 // ensure explicit version acl is still missing139 const versionAcl = await accessControl.getAccess(getScope(), 'version')140 expect(versionAcl).to.equal(null)141 })142 it('should deny access when user denies request', async () => {143 const getState = () => initState(optionDefaults, { ipfsProxy: true })144 const accessControl = new AccessControl(new Storage())145 const getScope = () => 'https://5.foo.tld/path/'146 const getIpfs = () => {}147 const requestAccess = Sinon.spy(async () => ({ allow: false }))148 const enable = createEnableCommand(getIpfs, getState, getScope, accessControl, requestAccess)149 const permissions = { commands: ['id', 'version'] }150 let error151 try {152 await enable(permissions)153 } catch (err) {154 error = err155 }156 expect(requestAccess.called).to.equal(true)157 expect(() => { if (error) throw error }).to.throw(`User denied access to selected commands over IPFS proxy: ${permissions.commands}`)158 })159 it('should not re-request if denied', async () => {160 const getState = () => initState(optionDefaults, { ipfsProxy: true })161 const accessControl = new AccessControl(new Storage())162 const getScope = () => 'https://6.foo.tld/path/'163 const getIpfs = () => {}164 const requestAccess = Sinon.spy(async () => ({ allow: false }))165 const enable = createEnableCommand(getIpfs, getState, getScope, accessControl, requestAccess)166 const permissions = { commands: ['id', 'version'] }167 let error168 try {169 await enable(permissions)170 } catch (err) {171 error = err172 }173 expect(requestAccess.called).to.equal(true)174 expect(() => { if (error) throw error }).to.throw(`User denied access to selected commands over IPFS proxy: ${permissions.commands}`)175 error = null176 requestAccess.resetHistory()177 try {178 await enable(permissions)179 } catch (err) {180 error = err181 }182 expect(requestAccess.called).to.equal(false)183 expect(() => { if (error) throw error }).to.throw(`User denied access to selected commands over IPFS proxy: ${permissions.commands}`)184 })185 it('should have a well-formed Error if denied', async () => {186 const getState = () => initState(optionDefaults, { ipfsProxy: true })187 const accessControl = new AccessControl(new Storage())188 const getScope = () => 'https://7.foo.tld/path/'189 const getIpfs = () => {}190 const requestAccess = Sinon.spy(async () => ({ allow: false }))191 const enable = createEnableCommand(getIpfs, getState, getScope, accessControl, requestAccess)192 const permissions = { commands: ['id', 'version'] }193 let error194 try {195 await enable(permissions)196 } catch (err) {197 error = err198 }199 expect(error.output.payload).to.deep.eql({200 code: 'ERR_IPFS_PROXY_ACCESS_DENIED',201 permissions: permissions.commands,202 scope: getScope(),203 isIpfsProxyAclError: true, // deprecated204 permission: permissions.commands[0] // deprecated205 })206 })207 it('should not re-request if allowed', async () => {208 const getState = () => initState(optionDefaults, { ipfsProxy: true })209 const accessControl = new AccessControl(new Storage())210 const getScope = () => 'https://8.foo.tld/path/'211 const getIpfs = () => {}212 const requestAccess = Sinon.spy(async () => ({ allow: true }))213 const enable = createEnableCommand(getIpfs, getState, getScope, accessControl, requestAccess)214 const permissions = { commands: ['id', 'version'] }215 await enable(permissions)216 expect(requestAccess.callCount).to.equal(1)217 await enable(permissions)218 expect(requestAccess.callCount).to.equal(1)219 })220 after(() => {221 delete global.URL222 })...
pre-acl.test.js
Source:pre-acl.test.js
1'use strict'2const { describe, it, before, after } = require('mocha')3const { expect } = require('chai')4const { URL } = require('url')5const Storage = require('mem-storage-area/Storage')6const Sinon = require('sinon')7const AccessControl = require('../../../../add-on/src/lib/ipfs-proxy/access-control')8const { createPreAcl } = require('../../../../add-on/src/lib/ipfs-proxy/pre-acl')9const { initState } = require('../../../../add-on/src/lib/state')10const { optionDefaults } = require('../../../../add-on/src/lib/options')11describe('lib/ipfs-proxy/pre-acl', () => {12 before(() => {13 global.URL = URL14 })15 it('should throw if access is disabled', async () => {16 const getState = () => initState(optionDefaults, { ipfsProxy: false })17 const accessControl = new AccessControl(new Storage())18 const getScope = () => 'https://ipfs.io/'19 const permission = 'files.add'20 const preAcl = createPreAcl(permission, getState, getScope, accessControl)21 let error22 try {23 await preAcl()24 } catch (err) {25 error = err26 }27 expect(() => { if (error) throw error }).to.throw('User disabled access to API proxy in IPFS Companion')28 expect(error.scope).to.equal(undefined)29 expect(error.permissions).to.be.equal(undefined)30 })31 it('should throw if ALL IPFS integrations are disabled for requested scope', async () => {32 const getState = () => initState(optionDefaults, {33 ipfsProxy: true,34 disabledOn: ['foo.tld']35 })36 const accessControl = new AccessControl(new Storage())37 const getScope = () => 'https://2.foo.tld/bar/buzz/'38 const permission = 'files.add'39 const preAcl = createPreAcl(permission, getState, getScope, accessControl)40 let error41 try {42 await preAcl()43 } catch (err) {44 error = err45 }46 expect(() => { if (error) throw error }).to.throw('User disabled access to API proxy in IPFS Companion')47 expect(error.scope).to.equal(undefined)48 expect(error.permissions).to.be.equal(undefined)49 })50 it('should request access if no grant exists', async () => {51 const getState = () => initState(optionDefaults, { ipfsProxy: true })52 const accessControl = new AccessControl(new Storage())53 const getScope = () => 'https://ipfs.io/'54 const permission = 'files.add'55 const requestAccess = Sinon.spy(async () => ({ allow: true }))56 const preAcl = createPreAcl(permission, getState, getScope, accessControl, requestAccess)57 await preAcl()58 expect(requestAccess.called).to.equal(true)59 })60 it('should deny access when user denies request', async () => {61 const getState = () => initState(optionDefaults, { ipfsProxy: true })62 const accessControl = new AccessControl(new Storage())63 const getScope = () => 'https://ipfs.io/'64 const permission = 'files.add'65 const requestAccess = Sinon.spy(async () => ({ allow: false }))66 const preAcl = createPreAcl(permission, getState, getScope, accessControl, requestAccess)67 let error68 try {69 await preAcl()70 } catch (err) {71 error = err72 }73 expect(requestAccess.called).to.equal(true)74 expect(() => { if (error) throw error }).to.throw(`User denied access to selected commands over IPFS proxy: ${permission}`)75 })76 it('should not re-request if denied', async () => {77 const getState = () => initState(optionDefaults, { ipfsProxy: true })78 const accessControl = new AccessControl(new Storage())79 const getScope = () => 'https://ipfs.io/'80 const permission = 'files.add'81 const requestAccess = Sinon.spy(async () => ({ allow: false }))82 const preAcl = createPreAcl(permission, getState, getScope, accessControl, requestAccess)83 let error84 try {85 await preAcl()86 } catch (err) {87 error = err88 }89 expect(requestAccess.called).to.equal(true)90 expect(() => { if (error) throw error }).to.throw(`User denied access to selected commands over IPFS proxy: ${permission}`)91 error = null92 requestAccess.resetHistory()93 try {94 await preAcl()95 } catch (err) {96 error = err97 }98 expect(requestAccess.called).to.equal(false)99 expect(() => { if (error) throw error }).to.throw(`User denied access to selected commands over IPFS proxy: ${permission}`)100 })101 it('should have a well-formed Error if denied', async () => {102 const getState = () => initState(optionDefaults, { ipfsProxy: true })103 const accessControl = new AccessControl(new Storage())104 const getScope = () => 'https://ipfs.io/'105 const permission = 'files.add'106 const requestAccess = Sinon.spy(async () => ({ allow: false }))107 const preAcl = createPreAcl(permission, getState, getScope, accessControl, requestAccess)108 let error109 try {110 await preAcl()111 } catch (err) {112 error = err113 }114 expect(error.output.payload).to.deep.eql({115 code: 'ERR_IPFS_PROXY_ACCESS_DENIED',116 permissions: [permission],117 scope: getScope(),118 isIpfsProxyAclError: true, // deprecated119 permission // deprecated120 })121 })122 it('should not re-request if allowed', async () => {123 const getState = () => initState(optionDefaults, { ipfsProxy: true })124 const accessControl = new AccessControl(new Storage())125 const getScope = () => 'https://ipfs.io/'126 const permission = 'files.add'127 const requestAccess = Sinon.spy(async () => ({ allow: true }))128 const preAcl = createPreAcl(permission, getState, getScope, accessControl, requestAccess)129 await preAcl()130 expect(requestAccess.callCount).to.equal(1)131 await preAcl()132 expect(requestAccess.callCount).to.equal(1)133 })134 after(() => {135 delete global.URL136 })...
RequestAccessCartItemsWindow.js
Source:RequestAccessCartItemsWindow.js
1Ext.ns('SailPoint', 'SailPoint.LCM', 'SailPoint.LCM.RequestAccess');2SailPoint.LCM.RequestAccess.cartWindow = null;3Ext.define('SailPoint.LCM.RequestAccessCartItemsWindow', {4 extend: 'Ext.window.Window',5 statics: {6 isReadOnly: true7 },8 grid: null,9 store: null,10 itemsRemoved: false,11 initComponent: function () {12 this.createStore();13 // splice the column that renders the remove button if necessary14 if (SailPoint.LCM.RequestAccessCartItemsWindow.isReadOnly === true) {15 this.gridMetaData.columns.splice(0, 1);16 }17 this.grid = new SailPoint.grid.PagingGrid({18 cls: 'smallFontGrid wrappingGrid',19 store: this.store,20 disableMouseTracking: true,21 region: 'center',22 columns: this.gridMetaData.columns,23 viewConfig: {24 scrollOffset: 0,25 stripeRows: true,26 getRowClass: function (record, rowIndex, rowParams, store) {27 return record.get("action");28 }29 }30 });31 var bva = {height:1020};32 if(SailPoint.getBrowserViewArea) {33 bva = SailPoint.getBrowserViewArea();34 }35 Ext.apply(this, {36 title: '#{msgs.cart}',37 items: [{38 xtype: 'panel',39 height: 100,40 bodyStyle: 'padding:5px 10px',41 region: 'north',42 html: "<h2>#{msgs.lcm_request_access_cart_title}</h2><br/><p>#{msgs.lcm_request_access_cart_description}</p>"43 },this.grid44 ],45 width: 768,46 height: bva.height - bva.height / 3,47 modal: true,48 closeAction: 'hide',49 plain: true,50 layout: 'border',51 buttonAlign: 'center',52 buttons: [53 {54 text: '#{msgs.lcm_checkout}',55 id: 'cartWindowCheckoutButton',56 margin: '10px',57 handler: function () {58 var checkoutEl = $('summaryForm:checkoutBtn');59 if (checkoutEl) {60 checkoutEl.click();61 }62 }63 },64 {65 text: '#{msgs.button_close}',66 cls : 'secondaryBtn',67 margin: '10px 0',68 handler: function () {69 this.close();70 },71 scope: this72 }73 ],74 listeners: {75 show: {76 fn: function (panel, eOpts) {77 panel.store.load();78 }79 }80 }81 });82 this.on('close', function () {83 if (this.itemsRemoved === true) {84 var list = Ext.getCmp('requestAccessList');85 if (list) {86 if (list.getActiveTab().getId() === 'requestAccessCurrentAccessGrid') {87 list.currentAccessGrid.getStore().load();88 } else {89 list.store.load();90 }91 }92 }93 this.itemsRemoved = false;94 });95 this.callParent(arguments);96 },97 createStore: function () {98 this.store = SailPoint.Store.createStore({99 fields: this.gridMetaData.fields,100 autoLoad: true,101 root: 'requests',102 totalProperty: 'count',103 pageSize: 10,104 url: SailPoint.getRelativeUrl('/lcm/cartShortDataSource.json'),105 sorters: [{property: 'name', direction: 'ASC'}],106 remoteSort: true,107 listeners: {108 load: {109 fn: function (store, records, success, eOpts) {110 var checkoutButton = Ext.getCmp('cartWindowCheckoutButton');111 if (checkoutButton) {112 checkoutButton.setDisabled(store.getTotalCount() == 0);113 }114 }115 }116 }117 });118 }119});120SailPoint.LCM.RequestAccess.removeRequest = function (id) {121 $("cartForm:cartRemoveRequestsId").value = id;122 $("cartForm:cartRemoveRequestsBtn").click();123};124/** Renderers **/125SailPoint.LCM.RequestAccess.buttonRenderer = function (value, metadata, record, rowIndex) {126 return '<div class="remover" onclick="SailPoint.LCM.RequestAccess.removeRequest(\'' + record.getId() + '\')"></div>';127};128SailPoint.LCM.RequestAccess.showCartWindow = function () {129 if (!SailPoint.LCM.RequestAccess.cartWindow) {130 SailPoint.LCM.RequestAccess.cartWindow = new SailPoint.LCM.RequestAccessCartItemsWindow({131 id: 'cartItemsWindow',132 gridMetaData: cartGridMetaData133 });134 }135 SailPoint.LCM.RequestAccess.cartWindow.show();136};137SailPoint.LCM.RequestAccess.refreshCartWindow = function () {138 if (SailPoint.LCM.RequestAccess.cartWindow) {139 SailPoint.LCM.RequestAccess.cartWindow.itemsRemoved = true;140 SailPoint.LCM.RequestAccess.cartWindow.store.loadPage(1);141 }...
lcmCreateAccountRequest.js
Source:lcmCreateAccountRequest.js
1Ext.ns('SailPoint', 'SailPoint.LCM', 'SailPoint.LCM.RequestAccess');2SailPoint.LCM.RequestAccess.OP = "Modify";3SailPoint.LCM.RequestAccess.ADD = "Add";4SailPoint.LCM.RequestAccess.MODIFY = "Modify";5SailPoint.LCM.RequestAccess.REMOVE = "Remove";6SailPoint.LCM.RequestAccess.DELETE = "Delete";7SailPoint.LCM.RequestAccess.ATTRIBUTE_OP_REMOVE = SailPoint.LCM.RequestAccess.REMOVE;8SailPoint.LCM.RequestAccess.ATTRIBUTE_OP_ADD = SailPoint.LCM.RequestAccess.ADD;9SailPoint.LCM.RequestAccess.APP = "IIQ";10SailPoint.LCM.RequestAccess.DETECTED = "detectedRoles";11SailPoint.LCM.RequestAccess.ASSIGNED = "assignedRoles";12SailPoint.LCM.RequestAccess.OBJECT_TYPE_ROLE = "role";13SailPoint.LCM.RequestAccess.OBJECT_TYPE_ENTITLEMENT = "entitlement";14SailPoint.LCM.RequestAccess.createCartRemoveRequest = function (record) {15 var request = new SailPoint.AccountRequest();16 request.operation = SailPoint.LCM.RequestAccess.DELETE;17 request.arguments.id = record.getId();18 request.requestId = record.getId();19 return request;20};21SailPoint.LCM.RequestAccess.createAccountRequestFromRecord = function (op, record, type) {22 var request = new SailPoint.AccountRequest();23 request.operation = SailPoint.LCM.RequestAccess.MODIFY;24 request.application = SailPoint.LCM.RequestAccess.APP;25 request.trackingId = SailPoint.LCM.RequestAccess.identityId;26 /** Add interesting stuff to the arguments **/27 request.arguments.id = record.getId();28 request.arguments.action = op;29 request.type = type;30 var attribute = new SailPoint.AttributeRequest();31 attribute.operation = op;32 var name = record.get('displayableName');33 if (!name || name === 'null') {34 name = record.get('attribute');35 }36 if (request.type !== 'entitlement') {37 request.arguments.name = record.get('name');38 request.arguments.displayableName = name;39 request.arguments.description = record.get('description');40 request.arguments.owner = record.get('owner-displayName') || '';41 attribute.valueXmlAttribute = record.raw.name;42 if (record.get('detectedOrAssigned')) {43 attribute.name = record.get('detectedOrAssigned');44 } else if (record.get('type')) {45 var roleType = record.get('type');46 if (SailPoint.LCM.RequestAccess.assignableTypes.indexOf(roleType) >= 0) {47 attribute.name = SailPoint.LCM.RequestAccess.ASSIGNED;48 } else {49 attribute.name = SailPoint.LCM.RequestAccess.DETECTED;50 }51 }52 //Need to set this regardless of assignmentId because we override id on detectedRoles53 request.arguments.roleId = record.get('roleId');54 if (!Ext.isEmpty(record.get('assignmentId'))) {55 attribute.assignmentId = record.get('assignmentId');56 }57 } else {58 request.attributeOpName = record.get('value');59 request.displayValue = name;60 request.attributeOp = SailPoint.LCM.RequestAccess.ADD;61 request.value = record.get('value');62 request.application = record.get('application-name');63 request.nativeIdentity = record.get('nativeIdentity');64 request.arguments.displayableName = name;65 request.arguments.description = record.get('description');66 request.arguments.owner = record.get('owner-displayName') || '';67 attribute.valueXmlAttribute = record.get('value');68 attribute.name = record.get('attribute');69 }70 attribute.operation = op;71 request.addAttribute(attribute);72 return request;...
requestAccess.test.js
Source:requestAccess.test.js
1import reducer from './requestAccess'2import {3 PATCH_REQUEST_ACCESS,4 SET_REQUEST_ACCESS,5 SET_REQUEST_ACCESS_ERROR,6 CLEAR_REQUEST_ACCESS,7} from '../actions/requestAccess'8describe('reducers/requestAccess', () => {9 it('should return the initial state', () => {10 expect(reducer(undefined, {})).toEqual({11 requestAccess: false,12 loading: false,13 })14 })15 it('should handle PATCH_REQUEST_ACCESS', () => {16 expect(17 reducer(undefined, {18 type: PATCH_REQUEST_ACCESS,19 })20 ).toEqual({21 loading: true,22 requestAccess: false,23 })24 })25 it('should handle SET_REQUEST_ACCESS', () => {26 expect(27 reducer(28 {29 requestAccess: false,30 loading: true,31 },32 {33 type: SET_REQUEST_ACCESS,34 }35 )36 ).toEqual({37 requestAccess: true,38 loading: false,39 })40 })41 it('should handle CLEAR_REQUEST_ACCESS', () => {42 expect(43 reducer(44 {45 loading: false,46 requestAccess: true,47 },48 {49 type: CLEAR_REQUEST_ACCESS,50 }51 )52 ).toEqual({53 loading: false,54 requestAccess: false,55 })56 })57 it('should handle SET_REQUEST_ACCESS_ERROR', () => {58 expect(59 reducer(60 {61 loading: false,62 requestAccess: true,63 },64 {65 type: SET_REQUEST_ACCESS_ERROR,66 payload: { error: 'something went wrong' },67 }68 )69 ).toEqual({70 loading: false,71 requestAccess: false,72 error: 'something went wrong',73 })74 })...
actions.js
Source:actions.js
1import { REQUEST_ACCESS } from 'state/SessionReducer'2export const requestAccessAction = body => async (3 dispatch,4 getState,5 { getFirebase, api }6) => {7 dispatch({8 type: `${REQUEST_ACCESS}_PENDING`9 })10 return api({11 body,12 dispatch,13 getState,14 getFirebase,15 path: 'requestAccess'16 }).then(({ requestAccess: { errors, ...requestAccess } = {} } = {}) => {17 if (errors) {18 dispatch({19 type: `${REQUEST_ACCESS}_FAILURE`,20 payload: errors21 })22 throw new Error(errors[0].message)23 } else {24 dispatch({25 type: `${REQUEST_ACCESS}_SUCCESS`,26 payload: requestAccess27 })28 }29 localStorage.setItem('hasRequestedAccess', true)30 return requestAccess31 })...
Using AI Code Generation
1describe('My First Test', function() {2 it('Visits the Kitchen Sink', function() {3 cy.requestAccess()4 })5})6Cypress.Commands.add('requestAccess', () => {7 cy.window().then(win => {8 win.navigator.serviceWorker.getRegistrations().then(function(registrations) {9 for (let registration of registrations) {10 registration.unregister();11 }12 });13 });14});15Cypress.Commands.add('requestAccess', () => {16 cy.window().then(win => {17 win.navigator.serviceWorker.getRegistrations().then(function(registrations) {18 for (let registration of registrations) {19 registration.unregister();20 }21 });22 });23});24I am not sure how to use this command in my test. I tried using cy.requestAccess() but it did not work. I am using cypress version 3.0.125cy.get('iframe').then($iframe => {26 const $body = $iframe.contents().find('body');27 cy.wrap($body).find('button').click();28});29cy.get('iframe').then($iframe => {30 const $body = $iframe.contents().find('body');31 cy.wrap($body).find('button').click();32});33cy.get('iframe').then($iframe => {34 const $body = $iframe.contents().find('body');35 cy.wrap($body).find('button').click();36});37cy.iframe().find('button').click();38cy.iframe().find('button').click();39cy.iframe().find('button').click();40cy.iframe().find('button').click();41cy.iframe().find('button').click();42cy.iframe().find('button').click();43cy.iframe().find('button').click();44cy.iframe().find('button').click();45cy.iframe().find('button').click();46cy.iframe().find('button').click();47cy.iframe().find('button').click
Using AI Code Generation
1Cypress.Commands.add('requestAccess', (email, password) => {2 cy.request({3 body: {4 },5 })6})7Cypress.Commands.add('login', (email, password) => {8 cy.request({9 body: {10 },11 }).then((response) => {12 window.localStorage.setItem('token', response.body.token)13 })14})15Cypress.Commands.add('login', (email, password) => {16 cy.request({17 body: {18 },19 }).then((response) => {20 window.localStorage.setItem('token', response.body.token)21 })22})23Cypress.Commands.add('login', (email, password) => {24 cy.request({25 body: {26 },27 }).then((response) => {28 window.localStorage.setItem('token', response.body.token)29 })30})31Cypress.Commands.add('login', (email, password) => {32 cy.request({33 body: {34 },35 }).then((response) => {36 window.localStorage.setItem('token', response.body.token)37 })38})39Cypress.Commands.add('login', (email, password) => {40 cy.request({41 body: {42 },43 }).then((response) => {44 window.localStorage.setItem('token', response.body.token)45 })46})47Cypress.Commands.add('login', (email, password) => {48 cy.request({
Using AI Code Generation
1describe('My First Test', () => {2 it('Does not do much!', () => {3 .then((response) => {4 expect(response.status).to.eq(200)5 })6 })7})
Using AI Code Generation
1require('cypress-plugin-tab');2describe('Test Suite', () => {3 it('Test Case', () => {4 cy.get('input[name="q"]').type('Cypress');5 cy.get('input[name="btnK"]').tab().click();6 });7});8require('cypress-plugin-tab');9{10 "env": {11 }12}13describe('Test Suite', () => {14 it('Test Case', () => {15 cy.get('input[name="q"]').type('Cypress');16 cy.get('input[name="btnK"]').tab().click();17 });18});19require('cypress-plugin-tab');20require('cypress-plugin-tab');
Using AI Code Generation
1Cypress.Commands.add('requestDesktopNotification', () => {2 cy.requestAccess('notifications')3})4describe('Test', () => {5 it('Request Desktop Notification', () => {6 cy.requestDesktopNotification()7 })8})9Cypress.Commands.add('requestDesktopNotification', () => {10})11describe('Test', () => {12 it('Request Desktop Notification', () => {13 cy.requestDesktopNotification()14 })15})16Cypress.Commands.add('acceptDesktopNotification', () => {17 cy.on('window:confirm', () => true)18})19describe('Test', () => {20 it('Accept Desktop Notification', () => {21 cy.acceptDesktopNotification()22 })23})24Cypress.Commands.add('denyDesktopNotification', () => {25 cy.on('window:confirm', () => false)26})27describe('Test', () => {28 it('Deny Desktop Notification', () => {29 cy.denyDesktopNotification()30 })31})32Cypress.Commands.add('checkDesktopNotificationEnabled', () => {33})
Using AI Code Generation
1describe('Desktop Notification', () => {2 before(() => {3 cy.requestAccess()4 })5 it('sends a desktop notification', () => {6 cy.task('desktop:notify', {7 })8 })9})10const notifier = require('node-notifier')11module.exports = (on, config) => {12 on('task', {13 'desktop:notify' (options) {14 notifier.notify(options)15 },16 })17}18const { BrowserWindow } = require('electron').remote19Cypress.Commands.add('requestAccess', () => {20 return new Cypress.Promise((resolve, reject) => {21 const win = BrowserWindow.getFocusedWindow()22 win.webContents.executeJavaScript(`23 Notification.requestPermission().then(function (result) {24 })25 `).then((result) => {26 if (result === 'granted') {27 resolve(result)28 } else {29 reject(result)30 }31 })32 })33})34declare namespace Cypress {
Using AI Code Generation
1import { requestAccess } from '@cypress/browser-tools'2describe('My First Test', () => {3 it('Does not do much!', () => {4 expect(true).to.equal(true)5 })6})7beforeEach(() => {8 requestAccess()9})10afterEach(() => {11 cy.task('uploadVideo')12})13const uploadVideo = require('cypress-video-upload-plugin')14module.exports = (on, config) => {15 on('task', {16 })17}18const uploadVideo = require('cypress-video-upload-plugin')19module.exports = (on, config) => {20 on('task', {21 })22}23{24}25{
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!