Skip to content

Commit

Permalink
Merge 52ff756 into e4a642b
Browse files Browse the repository at this point in the history
  • Loading branch information
PengTian0 committed Nov 29, 2017
2 parents e4a642b + 52ff756 commit 2807718
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
30 changes: 28 additions & 2 deletions spec/lib/api/2.0/callback-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,33 @@ describe('Http.Api.Callback v2.0', function () {
this.sandbox.restore();
});

it('should return a 200 for ucsCallback success', function () {
it('should return a 200 for ucsCallback success at northbound', function () {
this.sandbox.stub(eventsProtocol, 'publishHttpResponseUuid').resolves();
return helper.request()
.post('/api/2.0/ucsCallback')
.query({callbackId: callbackId})
.set('Content-Type', 'application/json')
.send(data)
.expect(200)
.expect(function(){
expect(eventsProtocol.publishHttpResponseUuid).to.be.calledOnce;
expect(eventsProtocol.publishHttpResponseUuid).to.be.calledWith(callbackId, data);
});
});

it('should return a 400 for ucsCallback failure at northbound', function () {
this.sandbox.stub(eventsProtocol, 'publishHttpResponseUuid').resolves();
return helper.request()
.post('/api/2.0/ucsCallback')
.set('Content-Type', 'application/json')
.send(data)
.expect(400)
.expect(function(){
expect(eventsProtocol.publishHttpResponseUuid).to.not.be.calledOnce;
});
});

it('should return a 200 for ucsCallback success at southbound', function () {
this.sandbox.stub(eventsProtocol, 'publishHttpResponseUuid').resolves();
return helper.request('http://localhost:8091')
.post('/api/2.0/ucsCallback')
Expand All @@ -35,7 +61,7 @@ describe('Http.Api.Callback v2.0', function () {
});
});

it('should return a 400 for ucsCallback failure', function () {
it('should return a 400 for ucsCallback failure at southbound', function () {
this.sandbox.stub(eventsProtocol, 'publishHttpResponseUuid').resolves();
return helper.request('http://localhost:8091')
.post('/api/2.0/ucsCallback')
Expand Down
30 changes: 30 additions & 0 deletions static/monorail-2.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4695,6 +4695,36 @@ paths:
tags:
- /api/2.0
x-swagger-router-controller: notification
/ucsCallback:
x-swagger-router-controller: callback
post:
operationId: ucsCallbackPost
summary: |
Callback for UCS nodes
description: |
Callback for UCS nodes
parameters:
- name: callbackId
in: query
description: |
callback id to identify data belongings
required: true
type: string
tags: [ "/api/2.0" ]
responses:
200:
description: Data is accepted and sent
schema:
type: object
400:
description: |
bad request parameter passed
schema:
$ref: '#/definitions/Error'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
produces:
- application/json
schemes:
Expand Down

0 comments on commit 2807718

Please sign in to comment.