use of com.microsoft.identity.common.internal.broker.ipc.IIpcStrategy in project microsoft-authentication-library-common-for-android by AzureAD.
the class BrokerOperationExecutorTests method getStrategyWithServiceExceptionResult.
// Gets a bundle back, the bundle contains a service exception result.
private IIpcStrategy getStrategyWithServiceExceptionResult() {
return new IIpcStrategy() {
@Override
@NonNull
public Bundle communicateToBroker(@NonNull final BrokerOperationBundle bundle) throws BrokerCommunicationException {
final Bundle result = new Bundle();
result.putBoolean(SERVICE_EXCEPTION_BUNDLE_KEY, true);
return result;
}
@Override
public Type getType() {
return MOCK_TYPE;
}
};
}
use of com.microsoft.identity.common.internal.broker.ipc.IIpcStrategy in project microsoft-authentication-library-common-for-android by AzureAD.
the class HelloCacheTests method testHelloShouldOnlyTriggerOnce.
@Test
public void testHelloShouldOnlyTriggerOnce() {
final String minimumVer = "1.0";
final String negotiatedVer = "2.5";
class MockStrategy implements IIpcStrategy {
int triggered = 0;
@Nullable
@Override
public Bundle communicateToBroker(@NonNull BrokerOperationBundle bundle) throws BrokerCommunicationException {
triggered += 1;
if (triggered == 2) {
Assert.fail("Should never be triggered");
}
final Bundle resultBundle = new Bundle();
resultBundle.putString(NEGOTIATED_BP_VERSION_KEY, negotiatedVer);
return resultBundle;
}
@Override
public Type getType() {
return Type.CONTENT_PROVIDER;
}
}
class MockController extends BrokerMsalController {
public MockController(Context applicationContext) {
super(applicationContext);
}
@Override
public HelloCache getHelloCache() {
return HelloCacheTests.this.getHelloCache(protocolA);
}
@Override
public String getActiveBrokerPackageName() {
return brokerAppName;
}
}
final MockController controller = new MockController(ApplicationProvider.getApplicationContext());
final MockStrategy strategy = new MockStrategy();
final CommandParameters parameters = CommandParameters.builder().requiredBrokerProtocolVersion(minimumVer).build();
try {
final String negotiatedProtocolVersion = controller.hello(strategy, parameters.getRequiredBrokerProtocolVersion());
final String negotiatedProtocolVersion2 = controller.hello(strategy, parameters.getRequiredBrokerProtocolVersion());
Assert.assertEquals(negotiatedProtocolVersion, negotiatedProtocolVersion2);
} catch (BaseException e) {
Assert.fail();
}
}
use of com.microsoft.identity.common.internal.broker.ipc.IIpcStrategy in project microsoft-authentication-library-common-for-android by AzureAD.
the class IpcStrategyTests method testIpcConnectionFailed.
protected void testIpcConnectionFailed(@NonNull final BrokerOperationBundle bundle) {
final IIpcStrategy strategy = getStrategy();
try {
strategy.communicateToBroker(bundle);
Assert.fail("Operation should fail.");
} catch (BaseException e) {
Assert.assertTrue(e instanceof BrokerCommunicationException);
Assert.assertSame(((BrokerCommunicationException) e).getCategory(), CONNECTION_ERROR);
Assert.assertSame(((BrokerCommunicationException) e).getStrategyType(), strategy.getType());
}
}
use of com.microsoft.identity.common.internal.broker.ipc.IIpcStrategy in project microsoft-authentication-library-common-for-android by AzureAD.
the class IpcStrategyTests method testOperationNotSupportedOnClientSide.
protected void testOperationNotSupportedOnClientSide(@NonNull final BrokerOperationBundle bundle) {
final IIpcStrategy strategy = getStrategy();
try {
strategy.communicateToBroker(bundle);
Assert.fail("Operation should fail.");
} catch (BaseException e) {
Assert.assertTrue(e instanceof BrokerCommunicationException);
Assert.assertSame(((BrokerCommunicationException) e).getCategory(), OPERATION_NOT_SUPPORTED_ON_CLIENT_SIDE);
Assert.assertSame(((BrokerCommunicationException) e).getStrategyType(), strategy.getType());
}
}
Aggregations