private void assertNoStat(String key) { assertThat(onHeap.getKnownStatistics()).doesNotContainKey(key); } }
@Test public void convertWhenConverterReturnsNullThenClaimIsRemoved() { MappedJwtClaimSetConverter converter = MappedJwtClaimSetConverter .withDefaults(Collections.emptyMap()); Map<String, Object> source = Collections.singletonMap(JwtClaimNames.ISS, null); Map<String, Object> target = converter.convert(source); assertThat(target).doesNotContainKey(JwtClaimNames.ISS); }
@Test public void testNull() throws Exception { when(tracingPlugin.isPseudonymizeUserNames()).thenReturn(true); when(tracingPlugin.isAnonymizeIPs()).thenReturn(true); final SpanWrapper span = createSpan(null, null); assertThat(span.getTags()).doesNotContainKey("username"); assertThat(span.getTags()).doesNotContainKey("username_disclosed"); assertThat(span.getTags()).doesNotContainKey(SpanUtils.IPV4_STRING); }
@Test public void notPromptForPasswordIfuserNameIsGivenInFile() throws Exception { // username specified in property file won't prompt for password properties.setProperty("security-username", "user"); doReturn(properties).when(connectCommand).loadProperties(any(File.class)); result = gfshParserRule.executeCommandWithInstance(connectCommand, "connect"); verify(gfsh, times(0)).readPassword(CliStrings.CONNECT__PASSWORD + ": "); assertThat(properties).doesNotContainKey("security-password"); }
@Test public void nullAuthenticatorShouldReturnNull() throws Exception { assertThat(this.securityProps).doesNotContainKey(SECURITY_PEER_AUTHENTICATOR); String result = this.authenticator.authenticate(this.member, this.securityProps, this.securityProps); // assertThat(result).isNull(); NOTE: old security used to return null assertThat(result).contains("Security check failed"); }
@Test public void nullManagerShouldReturnNull() throws Exception { assertThat(this.securityProps).doesNotContainKey(SECURITY_MANAGER); String result = this.authenticator.authenticate(this.member, this.securityProps, this.securityProps); assertThat(result).isNull(); }
@Test public void testNullIp() throws Exception { when(tracingPlugin.isPseudonymizeUserNames()).thenReturn(true); when(tracingPlugin.isAnonymizeIPs()).thenReturn(true); final SpanWrapper span = createSpan("test", null); assertThat(span.getTags()).containsEntry("username", "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"); assertThat(span.getTags()).doesNotContainKey("username_disclosed"); assertThat(span.getTags()).doesNotContainKey(SpanUtils.IPV4_STRING); }
@Test public void suppressEnvVariable_remove_existing_env_variable_and_add_variable_to_set_of_suppressed_variables() throws IOException { File workDir = temp.newFolder(); System2 system2 = Mockito.mock(System2.class); Map<String, String> env = new HashMap<>(); String key1 = randomAlphanumeric(3); env.put(key1, randomAlphanumeric(9)); when(system2.getenv()).thenReturn(env); AbstractCommand underTest = new AbstractCommand(ProcessId.ELASTICSEARCH, workDir, system2) { }; underTest.suppressEnvVariable(key1); assertThat(underTest.getEnvVariables()).doesNotContainKey(key1); assertThat(underTest.getSuppressedEnvVariables()).containsOnly(key1); }
@Test public void testNullUser() throws Exception { when(tracingPlugin.isPseudonymizeUserNames()).thenReturn(true); when(tracingPlugin.isAnonymizeIPs()).thenReturn(true); final SpanWrapper span = createSpan(null, IPV4.getHostAddress()); assertThat(span.getTags()).doesNotContainKey("username"); assertThat(span.getTags()).doesNotContainKey("username_disclosed"); assertThat(span.getTags()).containsEntry(Tags.PEER_HOST_IPV4.getKey(), InetAddresses.inetAddressToInt(IPV4_ANONYMIZED)); }
@Test public void testDontAnonymize() throws Exception { when(tracingPlugin.isPseudonymizeUserNames()).thenReturn(false); when(tracingPlugin.isAnonymizeIPs()).thenReturn(false); final SpanWrapper span = createSpanIpv4(); assertThat(span.getTags()).containsEntry("username", "test"); assertThat(span.getTags()).doesNotContainKey("username_disclosed"); assertThat(span.getTags()).containsEntry(Tags.PEER_HOST_IPV4.getKey(), InetAddresses.inetAddressToInt(IPV4)); }
@Test public void testAnonymizeIpV4() throws Exception { when(tracingPlugin.isPseudonymizeUserNames()).thenReturn(false); when(tracingPlugin.isAnonymizeIPs()).thenReturn(true); final SpanWrapper span = createSpanIpv4(); assertThat(span.getTags()).containsEntry("username", "test"); assertThat(span.getTags()).doesNotContainKey("username_disclosed"); assertThat(span.getTags()).containsEntry(Tags.PEER_HOST_IPV4.getKey(), InetAddresses.inetAddressToInt(IPV4_ANONYMIZED)); }
@Test public void testAnonymizeUserNameAndIpV4() throws Exception { when(tracingPlugin.isPseudonymizeUserNames()).thenReturn(true); when(tracingPlugin.isAnonymizeIPs()).thenReturn(true); final SpanWrapper span = createSpanIpv4(); assertThat(span.getTags()).containsEntry("username", "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"); assertThat(span.getTags()).doesNotContainKey("username_disclosed"); assertThat(span.getTags()).containsEntry(Tags.PEER_HOST_IPV4.getKey(), InetAddresses.inetAddressToInt(IPV4_ANONYMIZED)); }
@Test public void testAnonymizeIpv6() throws Exception { when(tracingPlugin.isPseudonymizeUserNames()).thenReturn(false); when(tracingPlugin.isAnonymizeIPs()).thenReturn(true); final SpanWrapper span = createSpan("test", IPV6.getHostAddress()); assertThat(span.getTags()).containsEntry("username", "test"); assertThat(span.getTags()).doesNotContainKey("username_disclosed"); assertThat(span.getTags()).containsEntry(Tags.PEER_HOST_IPV6.getKey(), IPV6_ANONYMIZED.getHostAddress()); }
/** Unlike Brave 3, Brave 4 propagates trace ids even when unsampled */ @Test public void propagates_sampledFalse() throws Exception { close(); httpTracing = HttpTracing.create(tracingBuilder(Sampler.NEVER_SAMPLE).build()); client = newClient(server.getPort()); server.enqueue(new MockResponse()); get(client, "/foo"); RecordedRequest request = server.takeRequest(); assertThat(request.getHeaders().toMultimap()) .containsKeys("x-b3-traceId", "x-b3-spanId") .doesNotContainKey("x-b3-parentSpanId") .containsEntry("x-b3-sampled", asList("0")); }
@Test public void testProcessSpan_withInvalidValueReturnsNull() throws Exception { // Given addServletParameter("invalid"); ClientSpanTagProcessor clientSpanLongTagProcessor = new ClientSpanLongTagProcessor(TYPE_ALL, TAG, REQUEST_PARAMETER_NAME); // When SpanWrapper span = runProcessor(clientSpanLongTagProcessor); // Then assertThat(mockTracer.finishedSpans()).hasSize(1); MockSpan mockSpan = mockTracer.finishedSpans().get(0); assertThat(mockSpan.tags()).doesNotContainKey(TAG); assertThat(span.getNumberTag(Tags.SAMPLING_PRIORITY.getKey())).isNotEqualTo(0); }
@Test public void testRequestMonitorNonMvcRequestDoMonitor() throws Exception { when(servletPlugin.isMonitorOnlySpringMvcRequests()).thenReturn(false); final MonitoredHttpRequest monitoredRequest = createMonitoredHttpRequest(nonMvcRequest); SpanContextInformation spanContext = requestMonitor.monitor(monitoredRequest); assertEquals("GET *.js", spanContext.getOperationName()); assertEquals("GET *.js", spanContext.getOperationName()); assertThat(registry.getTimers()).doesNotContainKey(getResponseTimeMetricName(spanContext.getOperationName(), "http")); assertThat(registry.getTimers()).containsKey(getResponseTimeMetricName("All", "http")); verify(monitoredRequest, times(1)).getRequestName(); assertThat(tags.get(Tags.SAMPLING_PRIORITY.getKey())).isNotEqualTo(0); }
@Test public void testNormalForwarding() throws Exception { testObject.monitored3(); assertThat(registry.getTimers()).doesNotContainKey(name("response_time").operationName("monitored1()").operationType("method_invocation").build()); assertThat(registry.getTimers()).doesNotContainKey(name("response_time").operationName("monitored2()").operationType("method_invocation").build()); assertThat(registry.getTimers()).containsKey(name("response_time").operationName("monitored3()").operationType("method_invocation").build()); assertThat(registry.getTimers()).doesNotContainKey(name("response_time").operationName("notMonitored()").operationType("method_invocation").build()); }
@Test public void testDoubleForwarding() throws Exception { testObject.monitored1(); assertThat(mockTracer.finishedSpans()).hasSize(3); Assert.assertEquals("monitored1()", mockTracer.finishedSpans().get(2).operationName()); assertEquals(tags.toString(), "1", tags.get(SpanUtils.PARAMETERS_PREFIX + "arg0")); assertEquals(tags.toString(), "test", tags.get(SpanUtils.PARAMETERS_PREFIX + "arg1")); assertThat(registry.getTimers()).containsKey(name("response_time").operationName("monitored1()").operationType("method_invocation").build()); assertThat(registry.getTimers()).containsKey(name("response_time").operationName("monitored2()").operationType("method_invocation").build()); assertThat(registry.getTimers()).containsKey(name("response_time").operationName("monitored3()").operationType("method_invocation").build()); assertThat(registry.getTimers()).doesNotContainKey(name("response_time").operationName("notMonitored()").operationType("method_invocation").build()); }
@Test public void removeRequestHeaderFilterWorks() { testClient.get() .uri("/headers") .header("Host", "www.removerequestheader.org") .header("X-Request-Foo", "Bar") .exchange() .expectStatus().isOk() .expectBody(Map.class).consumeWith(result -> { Map<String, Object> headers = getMap(result.getResponseBody(), "headers"); assertThat(headers).doesNotContainKey("X-Request-Foo"); }); }
@Test public void tableReferencesAreCaseSensitiveForPutAndGet() { createTablesIgnoringException(); kvs.put(UPPER_UPPER, ImmutableMap.of(CELL, BYTE_ARRAY), 1); kvs.put(LOWER_LOWER, ImmutableMap.of(CELL, SECOND_BYTE_ARRAY), 1); assertThat(kvs.get(UPPER_UPPER, ImmutableMap.of(CELL, 2L)).get(CELL).getContents()).contains(BYTE_ARRAY); assertThat(kvs.get(LOWER_UPPER, ImmutableMap.of(CELL, 2L))).doesNotContainKey(CELL); assertThat(kvs.get(LOWER_LOWER, ImmutableMap.of(CELL, 2L)).get(CELL).getContents()).contains(SECOND_BYTE_ARRAY); }