use of org.zaproxy.zap.extension.users.ContextUserAuthManager in project zaproxy by zaproxy.
the class PopupUserMenuItemHolder method resetMenu.
private void resetMenu() {
final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
// Remove existing popup menu items
if (visibleItself)
this.removeAll();
else {
for (ExtensionPopupMenuItem menu : getSubmenuItems()) {
mainPopupMenuItems.remove(menu);
}
subMenuItems.clear();
}
// Add a popup menu item for each existing users
Session session = Model.getSingleton().getSession();
List<Context> contexts = session.getContexts();
for (Context context : contexts) {
ContextUserAuthManager manager = extensionUserAuth.getContextUserAuthManager(context.getId());
for (User user : manager.getUsers()) {
ExtensionPopupMenuItem piicm;
if (visibleItself) {
piicm = getPopupUserMenu(context, user, this.getText());
this.add(piicm);
} else {
piicm = getPopupUserMenu(context, user, this.parentName);
piicm.setMenuIndex(this.getMenuIndex());
mainPopupMenuItems.add(piicm);
subMenuItems.add(piicm);
}
}
}
}
use of org.zaproxy.zap.extension.users.ContextUserAuthManager in project zaproxy by zaproxy.
the class PassiveScanDataUnitTest method shouldUseUsersOfFirstMatchedContextIfMessageApplicableToMultiple.
@Test
void shouldUseUsersOfFirstMatchedContextIfMessageApplicableToMultiple() {
// Given
HttpMessage msg = createMessage();
int contextId = 3;
Context matchCtxOne = mock(Context.class);
given(matchCtxOne.getId()).willReturn(contextId);
ExtensionUserManagement extUserMgmt = mock(ExtensionUserManagement.class);
List<User> expectedUsers = asList(mock(User.class), mock(User.class));
ContextUserAuthManager contextUserAuthManager = mock(ContextUserAuthManager.class);
given(extUserMgmt.getContextUserAuthManager(contextId)).willReturn(contextUserAuthManager);
given(contextUserAuthManager.getUsers()).willReturn(expectedUsers);
PassiveScanData.setExtUserMgmt(extUserMgmt);
Context matchCtxTwo = mock(Context.class);
given(session.getContextsForUrl(msg.getRequestHeader().getURI().toString())).willReturn(asList(matchCtxOne, matchCtxTwo));
// When
PassiveScanData psd = new PassiveScanData(msg);
// Then
assertThat(psd.getUsers(), is(equalTo(expectedUsers)));
}
Aggregations