refactored client constructor to support class dependancy injection
This commit is contained in:
parent
87681bc0e4
commit
c599902ad5
3 changed files with 24 additions and 23 deletions
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
package JobServ;
|
||||
|
||||
import java.io.File;
|
||||
import javax.net.ssl.SSLException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.AdditionalAnswers.delegatesTo;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
|
@ -41,7 +44,7 @@ import org.mockito.ArgumentMatchers;
|
|||
*/
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class JobServerAuthorizationTest {
|
||||
public class JobServerAuthenticationTest {
|
||||
|
||||
// Authorized client key/cert/ca
|
||||
private final String clientCa = "resources/client/ca.crt";
|
||||
|
|
@ -60,9 +63,9 @@ public class JobServerAuthorizationTest {
|
|||
|
||||
// Automates (graceful) shutdown at end of tests
|
||||
@Rule
|
||||
public final GrpcCleanupRule grpcCleanup = newCleanupRule();
|
||||
public final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule();
|
||||
|
||||
private final ShellServerGrpc.ShellServerImplBase = mock(ShellServerGrpc.ShellServerImplBase.class,
|
||||
private final ShellServerGrpc.ShellServerImplBase serviceImpl= mock(ShellServerGrpc.ShellServerImplBase.class,
|
||||
delegatesTo(new ShellServerGrpc.ShellServerImplBase() {}));
|
||||
|
||||
// badClient uses unauthorized certs
|
||||
|
|
@ -91,7 +94,7 @@ public class JobServerAuthorizationTest {
|
|||
grpcCleanup.register(InProcessServerBuilder.forName(serverName)
|
||||
.sslContext(serverContextBuilder.build())
|
||||
.directExecutor()
|
||||
.addService(this.serviceImpl);
|
||||
.addService(this.serviceImpl)
|
||||
.build().start());
|
||||
|
||||
this.serverSslInitialized = true;
|
||||
|
|
@ -177,6 +180,7 @@ public class JobServerAuthorizationTest {
|
|||
public void certAuthPosTest() {
|
||||
assertEquals(clientSslInitialized, true);
|
||||
int result = goodClient.sendNewJobMessage("test command");
|
||||
assertNotEquals(result, -2);
|
||||
Boolean assertCondition = result == -2;
|
||||
assertEquals(result, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue