@Test public void shouldCreateAnAESCipherFileWithTheCipherIfNotFound() throws IOException, CryptoException { assertThat(desCipherFile.exists()).isFalse(); assertThat(aesCipherFile.exists()).isFalse(); GoCipher goCipher = new GoCipher(systemEnvironment); assertThat(desCipherFile.exists()).isFalse(); assertThat(aesCipherFile.exists()).isTrue(); String plainText = goCipher.decrypt(goCipher.encrypt("user-password!")); assertThat(plainText).isEqualTo("user-password!"); assertThat(desCipherFile.exists()).isFalse(); assertThat(aesCipherFile.exists()).isTrue(); }
@Test public void constructorWithErrorCodeWhenErrorCodeIsValidThenCreated() { BearerTokenError error = new BearerTokenError(TEST_ERROR_CODE, TEST_HTTP_STATUS, null, null); assertThat(error.getErrorCode()).isEqualTo(TEST_ERROR_CODE); assertThat(error.getHttpStatus()).isEqualTo(TEST_HTTP_STATUS); assertThat(error.getDescription()).isNull(); assertThat(error.getUri()).isNull(); assertThat(error.getScope()).isNull(); }
@Test public void shouldReturnBoltUrl() { String actual = neo4jContainer.getBoltUrl(); assertThat(actual).isNotNull(); assertThat(actual).startsWith("bolt://"); }
@Test public void stepNameAndToString() { AssemblySnapshot stacktrace = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get()); MonoOnAssembly<?> test = new MonoOnAssembly<>(Mono.empty(), stacktrace); assertThat(test.toString()) .isEqualTo(test.stepName()) .startsWith("reactor.core.publisher.MonoOnAssemblyTest.stepNameAndToString(MonoOnAssemblyTest.java:"); }
@Test public void shouldReEncryptUsingNewKey() throws DecoderException, CryptoException { String originalCipherText = "mvcX9yrQsM4iPgm1tDxN1A=="; String newCipherText = DESEncrypter.reEncryptUsingNewKey(decodeHex("269298bc31c44620"), decodeHex("02644c13cb892962"), originalCipherText); assertThat(originalCipherText).isNotEqualTo(newCipherText); DESCipherProvider newCipher = mock(DESCipherProvider.class); when(newCipher.getKey()).thenReturn(decodeHex("02644c13cb892962")); DESEncrypter newEncrypter = new DESEncrypter(newCipher); assertThat(newEncrypter.decrypt(newCipherText)).isEqualTo("user-password!"); } }
@Test public void deserializeCasAuthenticationTestAfterEraseCredentialInvoked() throws Exception { CasAuthenticationToken token = mapper.readValue(CAS_TOKEN_CLEARED_JSON, CasAuthenticationToken.class); assertThat(((UserDetails) token.getPrincipal()).getPassword()).isNull(); }
private void validateHttpIeHelpContent(ResponseEntity<String> response) { validateContentType(response, MediaType.TEXT_PLAIN); assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull(); assertThat(response.getBody()).contains("Spring Initializr", "Examples:", "http") .doesNotContain("curl"); }
@Test public void genSaltGeneratesCorrectSaltPrefix() { assertThat(BCrypt.gensalt(4)).startsWith("$2a$04$"); assertThat(BCrypt.gensalt(31)).startsWith("$2a$31$"); }
@Test public void testToStringDoesntAttach() { assertThat(onDemand.toString()).isNotNull(); verify(mockExtensionFactory, never()).attach(any(), any()); }
@Test public void stacktraceHeaderTraceDescription() { StringBuilder sb = new StringBuilder(); AssemblySnapshot e = new AssemblySnapshot("1234", Traces.callSiteSupplierFactory.get()); FluxOnAssembly.fillStacktraceHeader(sb, String.class, e); assertThat(sb.toString()) .startsWith("\nAssembly trace from producer [java.lang.String]") .endsWith(", described as [1234] :\n"); }
@Test public void stepNameAndToString() { AssemblySnapshot stacktrace = new AssemblySnapshot(null, Traces.callSiteSupplierFactory.get()); MonoCallableOnAssembly<?> test = new MonoCallableOnAssembly<>(Mono.empty(), stacktrace); assertThat(test.toString()) .isEqualTo(test.stepName()) .startsWith("reactor.core.publisher.MonoCallableOnAssemblyTest.stepNameAndToString(MonoCallableOnAssemblyTest.java:"); }
@Test public void resolveWhenHeaderWithWrongSchemeIsPresentThenTokenIsNotResolved() { MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("Authorization", "Basic " + Base64.getEncoder().encodeToString("test:test".getBytes())); assertThat(this.resolver.resolve(request)).isNull(); }
private void validateSpringBootHelpContent(ResponseEntity<String> response) { validateContentType(response, MediaType.TEXT_PLAIN); assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull(); assertThat(response.getBody()) .contains("Service capabilities", "Supported dependencies") .doesNotContain("Examples:", "curl"); }
@Test public void shouldGenerateEncryptedText() throws CryptoException { String encrypt = aesEncrypter.encrypt("p@ssw0rd"); assertThat(encrypt).startsWith("AES"); assertThat(encrypt.split(":")).hasSize(3); }
@Test public void shouldReturnHttpUrl() { String actual = neo4jContainer.getHttpUrl(); assertThat(actual).isNotNull(); assertThat(actual).startsWith("http://"); } }