@@ -16,7 +16,7 @@ describe('src/meta', function() {
1616 } ) ;
1717 describe ( 'when creating a meta object' , ( ) => {
1818 beforeEach ( ( ) => {
19- this . actual = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , this . postFn , this . getFn , false ) ;
19+ this . actual = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , postFn : this . postFn , getFn : this . getFn , isBasic : false } ) ;
2020 } ) ;
2121 it ( 'it should return an object with a create asset function' , ( ) => {
2222 this . actual . create . should . be . a ( 'function' ) ;
@@ -46,7 +46,7 @@ describe('src/meta.create', function() {
4646 } ) ;
4747 describe ( 'given no asset type' , ( ) => {
4848 beforeEach ( ( ) => {
49- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , ( ) => {
49+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 } , ( ) => {
5050 } , ( ) => {
5151 } , false ) ;
5252 } ) ;
@@ -92,7 +92,7 @@ describe('src/meta.create', function() {
9292 RewireApi . __Rewire__ ( 'transformDataToAsset' , transformDataToAsset ) ;
9393 this . postFn = sinon . stub ( ) ;
9494
95- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , this . postFn , null ) ;
95+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , postFn : this . postFn , isBasic : false } ) ;
9696 this . actual = this . meta . create ( 'Actual' , { Value : 5.5 } ) ;
9797 } ) ;
9898 afterEach ( ( ) => {
@@ -127,7 +127,42 @@ describe('src/meta.create', function() {
127127 RewireApi . __Rewire__ ( 'transformDataToAsset' , transformDataToAsset ) ;
128128 this . postFn = sinon . stub ( ) ;
129129
130- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , this . postFn , null , true ) ;
130+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , postFn : this . postFn , isBasic : true } ) ;
131+ this . actual = this . meta . create ( 'Actual' , { Value : 5.5 } ) ;
132+ } ) ;
133+ afterEach ( ( ) => {
134+ RewireApi . __ResetDependency__ ( 'getV1Urls' ) ;
135+ RewireApi . __ResetDependency__ ( 'transformDataToAsset' ) ;
136+ } ) ;
137+ it ( 'it should post the asset creation to the REST URL endpoint with basic authentication headers' , ( ) => {
138+ this . postFn . calledWith ( 'rest URL/Actual' , this . assetData , this . headers ) . should . be . true ;
139+ } ) ;
140+ } ) ;
141+ } ) ;
142+ } ) ;
143+
144+ describe ( 'given implicit authentication' , ( ) => {
145+ describe ( 'given an asset type and asset data' , ( ) => {
146+ describe ( 'when creating an asset' , ( ) => {
147+ beforeEach ( ( ) => {
148+ this . assetData = { key : 'value' } ;
149+ this . headers = {
150+ Accept : 'application/json' ,
151+ 'Content-Type' : 'application/json' ,
152+ } ;
153+ const getV1Urls = sinon . mock ( )
154+ . withArgs ( 'h' , 'i' , 'http' , 80 )
155+ . returns ( {
156+ rest : 'rest URL'
157+ } ) ;
158+ const transformDataToAsset = sinon . mock ( )
159+ . withArgs ( { Value : 5.5 } )
160+ . returns ( this . assetData ) ;
161+ RewireApi . __Rewire__ ( 'getV1Urls' , getV1Urls ) ;
162+ RewireApi . __Rewire__ ( 'transformDataToAsset' , transformDataToAsset ) ;
163+ this . postFn = sinon . stub ( ) ;
164+
165+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , postFn : this . postFn } ) ;
131166 this . actual = this . meta . create ( 'Actual' , { Value : 5.5 } ) ;
132167 } ) ;
133168 afterEach ( ( ) => {
@@ -146,7 +181,7 @@ describe('src/meta.create', function() {
146181describe ( 'src/meta.update' , function ( ) {
147182 beforeEach ( ( ) => {
148183 this . actual = undefined ;
149- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , ( ) => {
184+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 } , ( ) => {
150185 } , ( ) => {
151186 } ) ;
152187 } ) ;
@@ -193,7 +228,7 @@ describe('src/meta.update', function() {
193228 RewireApi . __Rewire__ ( 'transformDataToAsset' , transformDataToAsset ) ;
194229 this . postFn = sinon . stub ( ) ;
195230
196- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , this . postFn , this . getFn , false ) ;
231+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , postFn : this . postFn , getFn : this . getFn , isBasic : false } ) ;
197232 this . actual = this . meta . update ( 'Actual:10011' , { Value : 5.5 } ) ;
198233 } ) ;
199234 afterEach ( ( ) => {
@@ -228,7 +263,7 @@ describe('src/meta.update', function() {
228263 RewireApi . __Rewire__ ( 'transformDataToAsset' , transformDataToAsset ) ;
229264 this . postFn = sinon . stub ( ) ;
230265
231- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , this . postFn , this . getFn , true ) ;
266+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , postFn : this . postFn , getFn : this . getFn , isBasic : true } ) ;
232267 this . actual = this . meta . update ( 'Actual:10011' , { Value : 5.5 } ) ;
233268 } ) ;
234269 afterEach ( ( ) => {
@@ -262,7 +297,7 @@ describe('src/meta.update', function() {
262297 RewireApi . __Rewire__ ( 'transformDataToAsset' , transformDataToAsset ) ;
263298 this . postFn = sinon . stub ( ) ;
264299
265- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , this . postFn , this . getFn , true ) ;
300+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , postFn : this . postFn , getFn : this . getFn , isBasic : true } ) ;
266301 this . actual = this . meta . update ( 'Actual:10011' , { Value : 5.5 } , 'change comment' ) ;
267302 } ) ;
268303 afterEach ( ( ) => {
@@ -279,7 +314,7 @@ describe('src/meta.update', function() {
279314describe ( 'src/meta.query' , function ( ) {
280315 beforeEach ( ( ) => {
281316 this . actual = undefined ;
282- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , ( ) => {
317+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 } , ( ) => {
283318 } , ( ) => {
284319 } ) ;
285320 } ) ;
@@ -336,7 +371,7 @@ describe('src/meta.query', function() {
336371 RewireApi . __Rewire__ ( 'getV1Urls' , getV1Urls ) ;
337372 this . postFn = sinon . stub ( ) ;
338373
339- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , this . postFn , this . getFn , false ) ;
374+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , postFn : this . postFn , getFn : this . getFn , isBasic : false } ) ;
340375 this . actual = this . meta . query ( this . query ) ;
341376 } ) ;
342377 afterEach ( ( ) => {
@@ -366,7 +401,7 @@ describe('src/meta.query', function() {
366401 RewireApi . __Rewire__ ( 'getV1Urls' , getV1Urls ) ;
367402 this . postFn = sinon . stub ( ) ;
368403
369- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , this . postFn , this . getFn , true ) ;
404+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , postFn : this . postFn , getFn : this . getFn , isBasic : true } ) ;
370405 this . actual = this . meta . query ( this . query ) ;
371406 } ) ;
372407 afterEach ( ( ) => {
@@ -383,7 +418,7 @@ describe('src/meta.query', function() {
383418describe ( 'src/meta.executeOperation' , function ( ) {
384419 beforeEach ( ( ) => {
385420 this . actual = undefined ;
386- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , ( ) => {
421+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 } , ( ) => {
387422 } , ( ) => {
388423 } ) ;
389424 } ) ;
@@ -419,7 +454,7 @@ describe('src/meta.executeOperation', function() {
419454 RewireApi . __Rewire__ ( 'getV1Urls' , getV1Urls ) ;
420455 this . postFn = sinon . stub ( ) ;
421456
422- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , this . postFn , this . getFn , false ) ;
457+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , postFn : this . postFn , getFn : this . getFn , isBasic : false } ) ;
423458 this . actual = this . meta . executeOperation ( 'Actual:10011' , this . operationName ) ;
424459 } ) ;
425460 afterEach ( ( ) => {
@@ -449,7 +484,7 @@ describe('src/meta.executeOperation', function() {
449484 RewireApi . __Rewire__ ( 'getV1Urls' , getV1Urls ) ;
450485 this . postFn = sinon . stub ( ) ;
451486
452- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , this . postFn , this . getFn , true ) ;
487+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , postFn : this . postFn , getFn : this . getFn , isBasic : true } ) ;
453488 this . actual = this . meta . executeOperation ( 'Actual:10011' , this . operationName ) ;
454489 } ) ;
455490 afterEach ( ( ) => {
@@ -483,7 +518,7 @@ describe('src/meta.queryDefinition', function() {
483518 RewireApi . __Rewire__ ( 'getV1Urls' , getV1Urls ) ;
484519 this . getFn = sinon . stub ( ) ;
485520
486- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , null , this . getFn , false ) ;
521+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , getFn : this . getFn , isBasic : false } ) ;
487522 this . actual = this . meta . queryDefinition ( ) ;
488523 } ) ;
489524 afterEach ( ( ) => {
@@ -510,7 +545,7 @@ describe('src/meta.queryDefinition', function() {
510545 RewireApi . __Rewire__ ( 'getV1Urls' , getV1Urls ) ;
511546 this . getFn = sinon . stub ( ) ;
512547
513- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , null , this . getFn , false ) ;
548+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , getFn : this . getFn , isBasic : false } ) ;
514549 this . actual = this . meta . queryDefinition ( 'Actual' ) ;
515550 } ) ;
516551 afterEach ( ( ) => {
@@ -537,7 +572,7 @@ describe('src/meta.queryDefinition', function() {
537572 RewireApi . __Rewire__ ( 'getV1Urls' , getV1Urls ) ;
538573 this . getFn = sinon . stub ( ) ;
539574
540- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , null , this . getFn , false ) ;
575+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , getFn : this . getFn , isBasic : false } ) ;
541576 this . actual = this . meta . getActivityStream ( 'Story:1234' ) ;
542577 } ) ;
543578 afterEach ( ( ) => {
@@ -564,7 +599,7 @@ describe('src/meta.queryDefinition', function() {
564599 RewireApi . __Rewire__ ( 'getV1Urls' , getV1Urls ) ;
565600 this . getFn = sinon . stub ( ) ;
566601
567- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , null , this . getFn , false ) ;
602+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , getFn : this . getFn , isBasic : false } ) ;
568603 this . actual = this . meta . queryDefinition ( ) ;
569604 } ) ;
570605 afterEach ( ( ) => {
@@ -591,7 +626,7 @@ describe('src/meta.queryDefinition', function() {
591626 RewireApi . __Rewire__ ( 'getV1Urls' , getV1Urls ) ;
592627 this . getFn = sinon . stub ( ) ;
593628
594- this . meta = createMeta ( 'h' , 'i' , 'http' , 80 , 'token' , null , this . getFn , true ) ;
629+ this . meta = createMeta ( { hostname : 'h' , instance : 'i' , protocol : 'http' , port : 80 , token : 'token' , getFn : this . getFn , isBasic : true } ) ;
595630 this . actual = this . meta . queryDefinition ( ) ;
596631 } ) ;
597632 afterEach ( ( ) => {
0 commit comments