Skip to content

Commit

Permalink
Feature/vulnerabilities (#75)
Browse files Browse the repository at this point in the history
* Security dependencies

* Update dependencies to latest minor and patch versions
* Add ignore for npm package of github templates

* Apply automagic fix for new version of codestyle
  • Loading branch information
victuxbb authored Oct 11, 2018
1 parent 683a79c commit 63ed0f3
Show file tree
Hide file tree
Showing 58 changed files with 2,319 additions and 2,442 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ coverage
.travis.yml
.idea
.eslintignore
.github
resources
2,520 changes: 891 additions & 1,629 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
"author": "One Punch Team",
"license": "ISC",
"devDependencies": {
"@s-ui/lint": "^2.13.0",
"@s-ui/lint": "^2.19.0",
"@s-ui/perf": "^1.4.0",
"@schibstedspain/openads-connector-api": "^1.2.0",
"babel-cli": "^6.24.0",
"babel-loader": "^7.1.4",
"babel-loader": "^7.1.5",
"babel-polyfill": "^6.23.0",
"babel-preset-sui": "1",
"babel-preset-sui": "^1.9.0",
"babel-register": "^6.24.0",
"chai": "^4.0.2",
"codecov": "^3.0.2",
"chai": "^4.2.0",
"codecov": "^3.1.0",
"istanbul": "^1.1.0-alpha.1",
"jsdom": "^11.11.0",
"mocha": "^3.4.2",
"jsdom": "^11.12.0",
"mocha": "^5.2.0",
"onchange": "^3.3.0",
"sinon": "^2.3.4"
},
Expand Down
195 changes: 117 additions & 78 deletions src/itest/openads/AddPositionUseCaseTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,72 @@ import {AD_AVAILABLE, AD_NO_BID} from '../../openads/domain/ad/adStatus'
import {POSITION_NOT_VISIBLE} from '../../openads/domain/position/positionStatus'
import AppNexusConnectorMock from './infrastructure/connector/AppNexusConnectorMock'

describe('Add Position use case', function () {
describe('given a position segmentation data', function () {
it('should return a Promise with a Domain Position and AppNexus data loaded', function (done) {
describe('Add Position use case', function() {
describe('given a position segmentation data', function() {
it('should return a Promise with a Domain Position and AppNexus data loaded', function(done) {
const appNexusConnectorMock = new AppNexusConnectorMock()

const stubLoadAd = sinon.stub(appNexusConnectorMock, 'loadAd')

stubLoadAd.returns(Promise.resolve({
status: AD_AVAILABLE,
data: {
adType: 'banner'
}
}))
stubLoadAd.returns(
Promise.resolve({
status: AD_AVAILABLE,
data: {
adType: 'banner'
}
})
)

const openAds = OpenAds.init({
config: {
Sources: {
'AppNexus': appNexusConnectorMock
AppNexus: appNexusConnectorMock
}
}
})

openAds.addPosition({
id: 'ad1',
name: 'ad number one',
source: 'AppNexus',
placement: 'es-cn-wph-ocasion-list-x_65',
segmentation: {
'es-sch-ads_name_page': 'cochesnet/ocasion/listado',
'es-sch-event_name': 'list',
'aa-sch-country_code': 'es',
'aa-sch-supply_type': 'wph',
'es-sch-section': 'ocasion',
'aa-sch-page_type': 'list',
'es-sch-adformat': 'x65'
},
sizes: [[300, 250], [320, 250]]
})
openAds
.addPosition({
id: 'ad1',
name: 'ad number one',
source: 'AppNexus',
placement: 'es-cn-wph-ocasion-list-x_65',
segmentation: {
'es-sch-ads_name_page': 'cochesnet/ocasion/listado',
'es-sch-event_name': 'list',
'aa-sch-country_code': 'es',
'aa-sch-supply_type': 'wph',
'es-sch-section': 'ocasion',
'aa-sch-page_type': 'list',
'es-sch-adformat': 'x65'
},
sizes: [[300, 250], [320, 250]]
})
.then(position => {
expect(position.ad.status, `The ad status is equal to ${position.ad.status}, instead it should be equal to 'AD_AVAILABLE'`).to.be.equals(AD_AVAILABLE)
expect(position.ad.data.adType, `The ad adType is equal to ${position.ad.data.adType}, instead it should be equal to 'banner'`).to.be.equals('banner')
expect(position.status, `The position status is equal to ${position.status}, instead it should be equal to 'POSITION_NOT_VISIBLE'`).to.be.equals(POSITION_NOT_VISIBLE)
expect(
position.ad.status,
`The ad status is equal to ${
position.ad.status
}, instead it should be equal to 'AD_AVAILABLE'`
).to.be.equals(AD_AVAILABLE)
expect(
position.ad.data.adType,
`The ad adType is equal to ${
position.ad.data.adType
}, instead it should be equal to 'banner'`
).to.be.equals('banner')
expect(
position.status,
`The position status is equal to ${
position.status
}, instead it should be equal to 'POSITION_NOT_VISIBLE'`
).to.be.equals(POSITION_NOT_VISIBLE)
done()
})
.catch(error => done(error))
})

it('should return a Rejected Promise with an PositionAdNotAvailableError', function (done) {
it('should return a Rejected Promise with an PositionAdNotAvailableError', function(done) {
const appnexusResponse = {
response: 'Thor is the son of Odin'
}
Expand All @@ -61,83 +79,104 @@ describe('Add Position use case', function () {

const stubLoadAd = sinon.stub(appNexusConnectorMock, 'loadAd')

stubLoadAd.returns(Promise.resolve({
status: AD_NO_BID,
data: appnexusResponse
}))
stubLoadAd.returns(
Promise.resolve({
status: AD_NO_BID,
data: appnexusResponse
})
)

const openAds = OpenAds.init({
config: {
Sources: {
'AppNexus': appNexusConnectorMock
AppNexus: appNexusConnectorMock
}
}
})

openAds.addPosition({
id: 'ad1',
name: 'ad number one',
source: 'AppNexus',
placement: 'es-cn-wph-ocasion-list-x_65',
segmentation: {
'es-sch-ads_name_page': 'cochesnet/ocasion/listado',
'es-sch-event_name': 'list',
'aa-sch-country_code': 'es',
'aa-sch-supply_type': 'wph',
'es-sch-section': 'ocasion',
'aa-sch-page_type': 'list',
'es-sch-adformat': 'x65'
},
sizes: [[300, 250], [320, 250]]
})
openAds
.addPosition({
id: 'ad1',
name: 'ad number one',
source: 'AppNexus',
placement: 'es-cn-wph-ocasion-list-x_65',
segmentation: {
'es-sch-ads_name_page': 'cochesnet/ocasion/listado',
'es-sch-event_name': 'list',
'aa-sch-country_code': 'es',
'aa-sch-supply_type': 'wph',
'es-sch-section': 'ocasion',
'aa-sch-page_type': 'list',
'es-sch-adformat': 'x65'
},
sizes: [[300, 250], [320, 250]]
})
.then(position => {
done(new Error('should generate a rejected promise!'))
})
.catch(error => {
expect(error.name, `AddPosition return a rejected Promise, in this case, we expect an error with name: 'PositionAdNotAvailableError', but we have received a ${error.name}`).to.be.equals('PositionAdNotAvailableError')
expect(error.position.id, `AddPosition return a rejected Promise, in this case, we expect that the position id was: 'ad1', but we have received a position id ${error.position.id}`).to.be.equals('ad1')
expect(error.position.ad.status, `The ad status is equal to ${error.position.ad.status}, instead it should be equal to 'AD_NO_BID'`).to.be.equals(AD_NO_BID)
expect(
error.name,
`AddPosition return a rejected Promise, in this case, we expect an error with name: 'PositionAdNotAvailableError', but we have received a ${
error.name
}`
).to.be.equals('PositionAdNotAvailableError')
expect(
error.position.id,
`AddPosition return a rejected Promise, in this case, we expect that the position id was: 'ad1', but we have received a position id ${
error.position.id
}`
).to.be.equals('ad1')
expect(
error.position.ad.status,
`The ad status is equal to ${
error.position.ad.status
}, instead it should be equal to 'AD_NO_BID'`
).to.be.equals(AD_NO_BID)
expect(error.position.ad.data).to.deep.equal(appnexusResponse)
done()
})
})

it('should call only one time loadAd from the connector', function (done) {
it('should call only one time loadAd from the connector', function(done) {
const appNexusConnectorMock = new AppNexusConnectorMock()

const stubLoadAd = sinon.stub(appNexusConnectorMock, 'loadAd')

stubLoadAd.returns(Promise.resolve({
status: AD_AVAILABLE,
data: {
adType: 'banner'
}
}))
stubLoadAd.returns(
Promise.resolve({
status: AD_AVAILABLE,
data: {
adType: 'banner'
}
})
)

const openAds = OpenAds.init({
config: {
Sources: {
'AppNexus': appNexusConnectorMock
AppNexus: appNexusConnectorMock
}
}
})

openAds.addPosition({
id: 'ad1',
name: 'ad number one',
source: 'AppNexus',
placement: 'es-cn-wph-ocasion-list-x_65',
segmentation: {
'es-sch-ads_name_page': 'cochesnet/ocasion/listado',
'es-sch-event_name': 'list',
'aa-sch-country_code': 'es',
'aa-sch-supply_type': 'wph',
'es-sch-section': 'ocasion',
'aa-sch-page_type': 'list',
'es-sch-adformat': 'x65'
},
sizes: [[300, 250], [320, 250]]
})
openAds
.addPosition({
id: 'ad1',
name: 'ad number one',
source: 'AppNexus',
placement: 'es-cn-wph-ocasion-list-x_65',
segmentation: {
'es-sch-ads_name_page': 'cochesnet/ocasion/listado',
'es-sch-event_name': 'list',
'aa-sch-country_code': 'es',
'aa-sch-supply_type': 'wph',
'es-sch-section': 'ocasion',
'aa-sch-page_type': 'list',
'es-sch-adformat': 'x65'
},
sizes: [[300, 250], [320, 250]]
})
.then(() => {
expect(stubLoadAd.calledOnce).to.be.true
done()
Expand Down
Loading

0 comments on commit 63ed0f3

Please sign in to comment.