use of org.hudsonci.service.NodeService in project hudson-2.x by hudson.
the class NodeServiceImplTest method getNodesDoesNotIncludeMaster.
@Test
public void getNodesDoesNotIncludeMaster() {
List<Node> nodes = new ArrayList<Node>();
nodes.add(node);
Node masterNode = hudson;
NodeService inst = spy(getInst());
doReturn(nodes).when(hudson).getNodes();
doReturn(true).when(security).hasPermission(node, Permission.READ);
// try to fake it out
doReturn(hudson).when(inst).getMasterNode();
doReturn(true).when(security).hasPermission(masterNode, Permission.READ);
List<Node> result = inst.getNodes();
assertThat(result, contains(node));
assertThat(result, not(contains(masterNode)));
}
use of org.hudsonci.service.NodeService in project hudson-2.x by hudson.
the class NodeServiceImplTest method getAllNodesSecurity.
@Test
public void getAllNodesSecurity() {
List<Node> nodes = new ArrayList<Node>();
nodes.add(node);
Node masterNode = hudson;
NodeService inst = spy(getInst());
doReturn(nodes).when(hudson).getNodes();
doReturn(hudson).when(inst).getMasterNode();
doReturn(true).when(security).hasPermission(masterNode, Permission.READ);
List<Node> result = inst.getAllNodes();
assertThat(result, not(contains(node)));
assertThat(result, contains(masterNode));
Mockito.verify(security).hasPermission(node, Permission.READ);
Mockito.verify(security).hasPermission(masterNode, Permission.READ);
}
use of org.hudsonci.service.NodeService in project hudson-2.x by hudson.
the class NodeServiceImplTest method getNodesSecurity.
@Test
public void getNodesSecurity() {
List<Node> nodes = new ArrayList<Node>();
nodes.add(node);
NodeService inst = spy(getInst());
doReturn(nodes).when(hudson).getNodes();
doReturn(true).when(security).hasPermission(node, Permission.READ);
List<Node> result = inst.getNodes();
assertThat(result, contains(node));
Mockito.verify(security).hasPermission(node, Permission.READ);
}
Aggregations