Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control endpoint is sensitive via property #2

Merged
merged 2 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
public class AsyncProfilerEndPoint implements MvcEndpoint {

private final AsyncProfilerFacade asyncProfilerFacade;
private final boolean isSensitive;

public AsyncProfilerEndPoint(AsyncProfilerFacade asyncProfilerFacade) {
public AsyncProfilerEndPoint(AsyncProfilerFacade asyncProfilerFacade, boolean isSensitive) {
this.asyncProfilerFacade = asyncProfilerFacade;
this.isSensitive = isSensitive;
}

@Override
Expand All @@ -26,7 +28,7 @@ public String getPath() {

@Override
public boolean isSensitive() {
return false;
return isSensitive;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public AsyncProfilerFacade asyncProfilerFacade(AsyncProfilerSupplier asyncProfil
}

@Bean
public AsyncProfilerEndPoint asyncProfilerEndPoint(AsyncProfilerFacade asyncProfilerFacade) {
return new AsyncProfilerEndPoint(asyncProfilerFacade);
public AsyncProfilerEndPoint asyncProfilerEndPoint(AsyncProfilerFacade asyncProfilerFacade,
@Value("${com.taboola.asyncprofiler.endpoint.sensitive:false}") boolean isSensitive) {
return new AsyncProfilerEndPoint(asyncProfilerFacade, isSensitive);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.taboola.async_profiler.spring;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
Expand All @@ -27,7 +29,7 @@ public class AsyncProfilerEndPointTest {
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
asyncProfilerEndPoint = new AsyncProfilerEndPoint(asyncProfilerFacade);
asyncProfilerEndPoint = new AsyncProfilerEndPoint(asyncProfilerFacade, false);
}

@Test
Expand Down Expand Up @@ -59,4 +61,9 @@ public void testGetVersion() {
assertEquals("1", asyncProfilerEndPoint.getVersion());
}

@Test
public void testIsSensitive() {
assertFalse(new AsyncProfilerEndPoint(asyncProfilerFacade, false).isSensitive());
assertTrue(new AsyncProfilerEndPoint(asyncProfilerFacade, true).isSensitive());
}
}