Skip to content

Commit

Permalink
Merge pull request #2 from taboola/control-endpoint-is-sensitive-via-…
Browse files Browse the repository at this point in the history
…property

1. Fix tests location
2. Control endpoint's isSensitive via property
tomsisso authored Nov 25, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents b05339f + b9e9db2 commit 0ff19fe
Showing 8 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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
@@ -26,7 +28,7 @@ public String getPath() {

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

@Override
Original file line number Diff line number Diff line change
@@ -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;
@@ -27,7 +29,7 @@ public class AsyncProfilerEndPointTest {
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
asyncProfilerEndPoint = new AsyncProfilerEndPoint(asyncProfilerFacade);
asyncProfilerEndPoint = new AsyncProfilerEndPoint(asyncProfilerFacade, false);
}

@Test
@@ -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());
}
}

0 comments on commit 0ff19fe

Please sign in to comment.