Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
knowledge-mw-service
Commits
42f3e974
Commit
42f3e974
authored
6 years ago
by
revathi
Committed by
kochhar
6 years ago
Browse files
Options
Download
Patches
Plain Diff
Issue #SB-3715 fix: functionality working
parent
8c140ea8
master
dependabot/npm_and_yarn/src/async-2.6.4
dependabot/npm_and_yarn/src/decode-uri-component-0.2.2
dependabot/npm_and_yarn/src/flat-and-mocha-5.0.2
dependabot/npm_and_yarn/src/handlebars-4.7.7
dependabot/npm_and_yarn/src/jsonwebtoken-9.0.0
dependabot/npm_and_yarn/src/lodash-4.17.21
dependabot/npm_and_yarn/src/minimist-and-project-sunbird/telemetry-sdk-and-handlebars-and-mkdirp-1.2.8
release-3.6.0
release-4.3.0
release-4.8.0
release-5.2.0
release-5.3.0
release-5.6.0
release-6.0.0
v1.13.3
v1.13
v1.12
v1.11.1
v1.11
v1.10.1
v1.10
v1.9
tmp-testPR
tmp-sunbird-bootcamp
tmp-rjshrjndrn-patch-1
tmp-revert-118-testPR
tmp-revert-110-logs
tmp-revert-99-revert-98-revert-97-revert-96-rjshrjndrn-patch-1
tmp-revert-98-revert-97-revert-96-rjshrjndrn-patch-1
tmp-revert-97-revert-96-rjshrjndrn-patch-1
tmp-revert-96-rjshrjndrn-patch-1
tmp-release-sonarcloud
tmp-release-2.6.0
tmp-release-2.3.0
tmp-release-2.1.1
tmp-release-2.1.0
tmp-release-2.1.0_pluginSearch
tmp-release-2.0.0
tmp-release-1.15
tmp-release-1.14.3
tmp-release-1.14
tmp-release-1.14-sp3
tmp-refactored-dev-deploy
tmp-master
tmp-loadtest
tmp-load-testing
tmp-jenkins-test
tmp-jenkins-pipeline
tmp-final-variable-refac
tmp-dial-assemble-api
tmp-content-update-read
tmp-circleci
release-5.6.0_RC1
release-5.2.0_RC1
release-4.8.5_RC1
release-4.8.0_RC2
release-4.8.0_RC1
release-4.3.0_RC1
release-3.8.0_RC3
release-3.8.0_RC2
release-3.8.0_RC1
release-3.7.0_RC2
release-3.7.0_RC1
release-3.6.0_RC1
release-3.2.0_RC2
release-3.2.0_RC1
release-3.1.0
release-3.1.0_RC2
release-3.1.0_RC1
release-3.0.1_RC1
release-3.0.0
release-3.0.0_RC1
release-2.10.0
release-2.10.0_RC2
release-2.10.0_RC1
release-2.9.0_RC3
release-2.9.0_RC2
release-2.9.0_RC1
release-2.8.0
release-2.8.0_RC4
release-2.8.0_RC3
release-2.8.0_RC2
release-2.8.0_RC1
release-2.7.0
release-2.7.0_RC2
release-2.7.0_RC1
release-2.6.0
release-2.6.0_RC4
release-2.6.0_RC3
release-2.6.0_RC2
release-2.6.0_RC1
release-2.3.0
release-2.3.0_RC2
release-2.3.0_RC1
release-2.1.1_RC1
release-2.1.0_RC2
release-2.1.0_RC1
release-2.0.0
release-2.0.0_RC5
release-2.0.0_RC4
release-2.0.0_RC3
release-2.0.0_RC2
release-2.0.0_RC1
release-1.15.0
release-1.15_RC7
release-1.15_RC6
release-1.15_RC5
release-1.15_RC4
release-1.15_RC3
release-1.15_RC2
release-1.15_RC1
release-1.14.0
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app.js
+8
-8
src/app.js
src/middlewares/filter.middleware.js
+35
-5
src/middlewares/filter.middleware.js
src/test/middlewares/filterMiddlewareSpec.js
+4
-2
src/test/middlewares/filterMiddlewareSpec.js
with
47 additions
and
15 deletions
+47
-15
src/app.js
+
8
−
8
View file @
42f3e974
...
...
@@ -38,14 +38,14 @@ const dialServiceBaseUrl = process.env.sunbird_dial_service_api_base_url || 'htt
const
whiteListedChannelList
=
process
.
env
.
sunbird_content_service_whitelisted_channels
const
blackListedChannelList
=
process
.
env
.
sunbird_content_service_blacklisted_channels
const
whitelistedFrameworkList
=
process
.
env
.
sunbird_content_
service_whitelis
te
d
_framework
const
blacklistedFrameworkList
=
process
.
env
.
sunbird_content_
service_blacklis
te
d
_framework
const
whitelistedMimeTypeList
=
process
.
env
.
sunbird_content_
service_whitelisted_mimeType
const
blacklistedMimeTypeList
=
process
.
env
.
sunbird_content_
service_blacklisted_mimeType
const
whitelistedContentTypeList
=
process
.
env
.
sunbird_content_
service_whitelis
te
d
_content
T
ype
const
blacklistedContentTypeList
=
process
.
env
.
sunbird_content_
service_blacklis
te
d
_content
T
ype
const
whitelistedResourceTypeList
=
process
.
env
.
sunbird_content_
service_whitelis
te
d
_resource
T
ype
const
blacklistedResourceTypeList
=
process
.
env
.
sunbird_content_
service_blacklis
te
d
_resource
T
ype
const
whitelistedFrameworkList
=
process
.
env
.
sunbird_content_
fil
te
r
_framework
_whitelist
const
blacklistedFrameworkList
=
process
.
env
.
sunbird_content_
fil
te
r
_framework
_blacklist
const
whitelistedMimeTypeList
=
process
.
env
.
sunbird_content_
filter_mimetype_whitelist
const
blacklistedMimeTypeList
=
process
.
env
.
sunbird_content_
filter_mimetype_blacklist
const
whitelistedContentTypeList
=
process
.
env
.
sunbird_content_
fil
te
r
_content
t
ype
_whitelist
const
blacklistedContentTypeList
=
process
.
env
.
sunbird_content_
fil
te
r
_content
t
ype
_blacklist
const
whitelistedResourceTypeList
=
process
.
env
.
sunbird_content_
fil
te
r
_resource
t
ype
_whitelist
const
blacklistedResourceTypeList
=
process
.
env
.
sunbird_content_
fil
te
r
_resource
t
ype
_blacklist
const
producerId
=
process
.
env
.
sunbird_environment
+
'
.
'
+
process
.
env
.
sunbird_instance
+
'
.content-service
'
...
...
This diff is collapsed.
Click to expand it.
src/middlewares/filter.middleware.js
+
35
−
5
View file @
42f3e974
...
...
@@ -7,11 +7,41 @@ var filename = path.basename(__filename)
function
addMetaFilters
(
req
,
res
,
next
)
{
// If the request body has filter by metaFilter data, continue with the same filter, do not alter the values
// else call the getMetaSearchData() function to generate the JSON Object for the meta filters
filterService
.
getMetaSearchData
(
function
()
{
// Generate JSON and return
return
setFilterJSON
()
})
// else call the getMetaSearchString() function to generate the search string for the meta filters
if
(
req
&&
req
.
body
&&
req
.
body
.
request
&&
req
.
body
.
request
.
filters
&&
req
.
body
.
request
.
filters
.
channel
&&
req
.
body
.
request
.
filters
.
framework
&&
req
.
body
.
request
.
filters
.
contentType
&&
req
.
body
.
request
.
filters
.
mimeType
&&
req
.
body
.
request
.
filters
.
resourceType
)
{
next
()
}
else
{
filterService
.
getMetaSearchString
(
function
(
err
,
searchJSON
)
{
console
.
log
(
'
err
'
,
err
)
console
.
log
(
'
channels
'
,
searchJSON
)
if
(
err
)
{
LOG
.
error
(
utilsService
.
getLoggerData
({},
'
ERROR
'
,
filename
,
'
addChannelFilters
'
,
'
failed to get channels
'
))
}
else
if
(
searchJSON
&&
(
!
_
.
isEmpty
(
searchJSON
)))
{
if
(
req
.
body
.
request
.
filters
.
channel
===
undefined
)
{
req
.
body
.
request
.
filters
.
channel
=
searchJSON
.
channel
}
if
(
req
.
body
.
request
.
filters
.
framework
===
undefined
)
{
req
.
body
.
request
.
filters
.
framework
=
searchJSON
.
framework
}
if
(
req
.
body
.
request
.
filters
.
contentType
===
undefined
)
{
req
.
body
.
request
.
filters
.
contentType
=
searchJSON
.
contentType
}
if
(
req
.
body
.
request
.
filters
.
mimeType
===
undefined
)
{
req
.
body
.
request
.
filters
.
mimeType
=
searchJSON
.
mimeType
}
if
(
req
.
body
.
request
.
filters
.
resourceType
===
undefined
)
{
req
.
body
.
request
.
filters
.
resourceType
=
searchJSON
.
resourceType
}
LOG
.
info
(
utilsService
.
getLoggerData
({},
'
INFO
'
,
filename
,
'
addChannelFilters
'
,
'
added channel filter
'
,
req
.
body
.
request
.
filters
))
console
.
log
(
'
req filters
'
,
req
.
body
.
request
.
filters
)
}
next
()
})
}
}
function
setFilterJSON
()
{
...
...
This diff is collapsed.
Click to expand it.
src/test/middlewares/filterMiddlewareSpec.js
+
4
−
2
View file @
42f3e974
...
...
@@ -2,8 +2,10 @@ describe('Initialization of meta filters', function () {
it
(
'
check for the request and then do next
'
,
function
()
{})
it
(
'
check for no request and get config
'
,
function
()
{})
it
(
'
check for the filter object property exists in the request body
'
,
function
()
{})
it
(
'
if filter object property is equal to response body property then do not append property to filter
'
,
function
()
{})
it
(
'
if the filter object property is not equal to response body property then append property to filter
'
,
function
()
{})
it
(
'
if filter object property is equal to response body property then do not append
'
+
'
property to filter
'
,
function
()
{})
it
(
'
if the filter object property is not equal to response body property then append
'
+
'
property to filter
'
,
function
()
{})
it
(
'
check for getMetaSearchData method creates proper whitelisted search data
'
,
function
()
{})
it
(
'
check for getMetaSearchData method creates proper blacklisted search data
'
,
function
()
{})
})
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets