### Question:
JWTAuthOptionsFactory { public JWTAuthOptions createForExternalPublicKey(final File externalPublicKeyFile) { final byte[] externalJwtPublicKey = readPublicKey(externalPublicKeyFile); final String base64EncodedPublicKey = Base64.getEncoder().encodeToString(externalJwtPublicKey); return new JWTAuthOptions() .setPermissionsClaimKey(PERMISSIONS) .addPubSecKey( new PubSecKeyOptions().setAlgorithm(ALGORITHM).setPublicKey(base64EncodedPublicKey)); }  JWTAuthOptions createForExternalPublicKey(final File externalPublicKeyFile); JWTAuthOptions createWithGeneratedKeyPair();  }### Answer:
@Test public void createsOptionsUsingPublicKeyFile() throws URISyntaxException { final JWTAuthOptionsFactory jwtAuthOptionsFactory = new JWTAuthOptionsFactory(); final File enclavePublicKeyFile = Paths.get(ClassLoader.getSystemResource("authentication/jwt_public_key").toURI()) .toAbsolutePath() .toFile(); final JWTAuthOptions jwtAuthOptions = jwtAuthOptionsFactory.createForExternalPublicKey(enclavePublicKeyFile); assertThat(jwtAuthOptions.getPubSecKeys()).hasSize(1); assertThat(jwtAuthOptions.getPubSecKeys().get(0).getAlgorithm()).isEqualTo("RS256"); assertThat(jwtAuthOptions.getPubSecKeys().get(0).getSecretKey()).isNull(); assertThat(jwtAuthOptions.getPubSecKeys().get(0).getPublicKey()).isEqualTo(JWT_PUBLIC_KEY); }
@Test public void failsToCreateOptionsWhenPublicKeyFileDoesNotExist() { final JWTAuthOptionsFactory jwtAuthOptionsFactory = new JWTAuthOptionsFactory(); final File enclavePublicKeyFile = new File("doesNotExist"); assertThatThrownBy(() -> jwtAuthOptionsFactory.createForExternalPublicKey(enclavePublicKeyFile)) .isInstanceOf(IllegalStateException.class) .hasMessage("Authentication RPC public key could not be read"); }
@Test public void failsToCreateOptionsWhenPublicKeyFileIsInvalid() throws IOException { final JWTAuthOptionsFactory jwtAuthOptionsFactory = new JWTAuthOptionsFactory(); final Path enclavePublicKey = Files.createTempFile("enclave", "pub"); Files.writeString(enclavePublicKey, "invalidDataNo---HeadersAndNotBase64"); assertThatThrownBy( () -> jwtAuthOptionsFactory.createForExternalPublicKey(enclavePublicKey.toFile())) .isInstanceOf(IllegalStateException.class) .hasMessage("Authentication RPC public key file format is invalid"); }