use of org.junit.Assert.assertTrue in project rskj by rsksmart.
the class ChannelManagerImplTest method broadcastTransaction_broadcastToAllActivePeers.
@Test
public void broadcastTransaction_broadcastToAllActivePeers() {
final Transaction transaction = mock(Transaction.class);
when(transaction.getHash()).thenReturn(TestUtils.randomHash());
final Map<NodeID, Channel> activePeers = peersForTests(2);
final ChannelManager channelManager = new ChannelManagerImpl(mock(RskSystemProperties.class), mock(SyncPool.class));
channelManager.setActivePeers(activePeers);
final Set<NodeID> broadcastedTo = channelManager.broadcastTransaction(transaction, Collections.emptySet());
Assert.assertTrue(activePeers.keySet().stream().allMatch(activePeer -> broadcastedTo.contains(activePeer)));
Assert.assertEquals(2, broadcastedTo.size());
}
use of org.junit.Assert.assertTrue in project rskj by rsksmart.
the class ChannelManagerImplTest method broadcastTransactions_broadcastToAllActivePeers.
@Test
public void broadcastTransactions_broadcastToAllActivePeers() {
final Transaction transaction = mock(Transaction.class);
when(transaction.getHash()).thenReturn(TestUtils.randomHash());
final List<Transaction> transactions = Collections.singletonList(transaction);
final Map<NodeID, Channel> activePeers = peersForTests(2);
final ChannelManager channelManager = new ChannelManagerImpl(mock(RskSystemProperties.class), mock(SyncPool.class));
channelManager.setActivePeers(activePeers);
final Set<NodeID> broadcastedTo = channelManager.broadcastTransactions(transactions, Collections.emptySet());
Assert.assertTrue(activePeers.keySet().stream().allMatch(activePeer -> broadcastedTo.contains(activePeer)));
Assert.assertEquals(2, broadcastedTo.size());
}
use of org.junit.Assert.assertTrue in project keycloak by keycloak.
the class AccountFormServiceTest method removeTotpAsDifferentUser.
@Test
public void removeTotpAsDifferentUser() {
UserResource user1 = ApiUtil.findUserByUsernameId(testRealm(), "user-with-one-configured-otp");
CredentialRepresentation otpCredential = user1.credentials().stream().filter(credentialRep -> OTPCredentialModel.TYPE.equals(credentialRep.getType())).findFirst().get();
// Login as evil user (test-user@localhost) and setup TOTP
totpPage.open();
loginPage.login("test-user@localhost", "password");
Assert.assertTrue(totpPage.isCurrent());
totpPageSetup();
totpPage.configure(totp.generateTOTP(totpPage.getTotpSecret()));
Assert.assertEquals("Mobile authenticator configured.", profilePage.getSuccess());
String currentStateChecker = driver.findElement(By.id("stateChecker")).getAttribute("value");
// Try to delete TOTP of "user-with-one-configured-otp" by replace ID of the TOTP credential in the request
String currentURL = driver.getCurrentUrl();
String formParameters = "stateChecker=" + currentStateChecker + "&submitAction=Delete" + "&credentialId=" + otpCredential.getId();
URLUtils.sendPOSTRequestWithWebDriver(currentURL, formParameters);
// Assert credential of "user-with-one-configured-otp" was NOT deleted and is still present for the user
Assert.assertTrue(user1.credentials().stream().anyMatch(credentialRepresentation -> credentialRepresentation.getType().equals(OTPCredentialModel.TYPE)));
// Remove TOTP for "test-user" and logout
totpPage.removeTotp();
totpPage.logout();
}
Aggregations