Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Storage
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSDU
OSDU Data Platform
System
Storage
Commits
56c336c7
Commit
56c336c7
authored
2 years ago
by
Alok Joshi
Browse files
Options
Downloads
Patches
Plain Diff
unit tests
parent
761414f7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!744
Upgraded packages to mitigated vulns in netty, guava, snakeyaml
,
!626
Bypass info and swagger apis in collaboration filter
Pipeline
#167355
failed
2 years ago
Stage: review
Stage: build
Stage: coverage
Stage: containerize
Stage: scan
Stage: deploy
Stage: integration
Changes
1
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage-core/src/test/java/org/opengroup/osdu/storage/util/CollaborationFilterTest.java
+26
-2
26 additions, 2 deletions
.../opengroup/osdu/storage/util/CollaborationFilterTest.java
with
26 additions
and
2 deletions
storage-core/src/test/java/org/opengroup/osdu/storage/util/CollaborationFilterTest.java
+
26
−
2
View file @
56c336c7
...
...
@@ -18,6 +18,7 @@ import javax.servlet.http.HttpServletResponse;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
static
org
.
mockito
.
Mockito
.
never
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
mockito
.
MockitoAnnotations
.
initMocks
;
...
...
@@ -48,17 +49,16 @@ public class CollaborationFilterTest {
@Before
public
void
setup
()
{
initMocks
(
this
);
}
@Test
public
void
shouldThrowException_ifCollaborationHeaderProvided_whenCollaborationFeatureFlagDisabled
()
throws
IOException
,
ServletException
{
when
(
httpServletRequest
.
getHeader
(
DATA_PARTITION_ID
)).
thenReturn
(
DATA_PARTITION
);
when
(
httpServletRequest
.
getRequestURI
()).
thenReturn
(
"https://my-service-url"
);
when
(
iCollaborationFeatureFlag
.
isFeatureEnabled
(
FEATURE_NAME
)).
thenReturn
(
false
);
when
(
httpServletRequest
.
getHeader
(
X_COLLABORATION_HEADER_NAME
)).
thenReturn
(
COLLABORATION_DIRECTIVES
);
when
(
httpServletResponse
.
getWriter
()).
thenReturn
(
writer
);
collaborationFilter
.
doFilter
(
httpServletRequest
,
httpServletResponse
,
filterChain
);
verify
(
httpServletResponse
).
setContentType
(
"application/json"
);
...
...
@@ -66,4 +66,28 @@ public class CollaborationFilterTest {
AppError
errorResponse
=
new
AppError
(
HttpStatus
.
SC_LOCKED
,
"Locked"
,
"Feature is not enabled on this environment"
);
verify
(
writer
).
write
(
CollaborationFilter
.
appErrorToJson
(
errorResponse
));
}
@Test
public
void
shouldSkipFilter_ifUrlContainsHealthEndpoint
()
{
when
(
httpServletRequest
.
getRequestURI
()).
thenReturn
(
"https://my-service-url/api/storage/v2/health"
);
verify
(
iCollaborationFeatureFlag
,
never
()).
isFeatureEnabled
(
FEATURE_NAME
);
}
@Test
public
void
shouldSkipFilter_ifUrlContainsInfoEndpoint
()
{
when
(
httpServletRequest
.
getRequestURI
()).
thenReturn
(
"https://my-service-url/api/storage/v2/info"
);
verify
(
iCollaborationFeatureFlag
,
never
()).
isFeatureEnabled
(
FEATURE_NAME
);
}
@Test
public
void
shouldSkipFilter_ifUrlContainsSwaggerEndpoint
()
{
when
(
httpServletRequest
.
getRequestURI
()).
thenReturn
(
"https://my-service-url/api/storage/v2/swagger-ui/index.html"
);
verify
(
iCollaborationFeatureFlag
,
never
()).
isFeatureEnabled
(
FEATURE_NAME
);
}
@Test
public
void
shouldSkipFilter_ifUrlContainsApiDocsEndpoint
()
{
when
(
httpServletRequest
.
getRequestURI
()).
thenReturn
(
"https://my-service-url/api/storage/v2/v3/api-docs"
);
verify
(
iCollaborationFeatureFlag
,
never
()).
isFeatureEnabled
(
FEATURE_NAME
);
}
}
This diff is collapsed.
Click to expand it.
Alok Joshi
@ajoshi19
mentioned in commit
a734da82
·
2 years ago
mentioned in commit
a734da82
mentioned in commit a734da82cb4119a583d844b4d95a8dbc414c7b32
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment