@@ -173,14 +173,15 @@ var _ = Describe("ExpiringLicenseService", func() {
173173
174174 client .AppendHandlers (
175175 ghttp .CombineHandlers (
176- ghttp .VerifyRequest ("GET" , "/api/v0/deployed /products" ),
177- ghttp .RespondWith (http .StatusOK , createDeployedProductResponse ( deployedGUID , deployedExpiryDate , deployedLabel )),
176+ ghttp .VerifyRequest ("GET" , "/api/v0/staged /products" ),
177+ ghttp .RespondWith (http .StatusOK , createStagedProductResponse ( stagedGUID , stagedExpiryDate , stagedLabel )),
178178 ),
179179 )
180+
180181 client .AppendHandlers (
181182 ghttp .CombineHandlers (
182- ghttp .VerifyRequest ("GET" , "/api/v0/staged /products" ),
183- ghttp .RespondWith (http .StatusOK , createStagedProductResponse ( stagedGUID , stagedExpiryDate , stagedLabel )),
183+ ghttp .VerifyRequest ("GET" , "/api/v0/deployed /products" ),
184+ ghttp .RespondWith (http .StatusOK , createDeployedProductResponse ( deployedGUID , deployedExpiryDate , deployedLabel )),
184185 ),
185186 )
186187
@@ -201,14 +202,15 @@ var _ = Describe("ExpiringLicenseService", func() {
201202
202203 client .AppendHandlers (
203204 ghttp .CombineHandlers (
204- ghttp .VerifyRequest ("GET" , "/api/v0/deployed /products" ),
205- ghttp .RespondWith (http .StatusOK , createDeployedProductResponse ( deployedGUID , deployedExpiryDate , deployedLabel )),
205+ ghttp .VerifyRequest ("GET" , "/api/v0/staged /products" ),
206+ ghttp .RespondWith (http .StatusOK , createStagedProductResponse ( stagedGUID , stagedExpiryDate , stagedLabel )),
206207 ),
207208 )
209+
208210 client .AppendHandlers (
209211 ghttp .CombineHandlers (
210- ghttp .VerifyRequest ("GET" , "/api/v0/staged /products" ),
211- ghttp .RespondWith (http .StatusOK , createStagedProductResponse ( stagedGUID , stagedExpiryDate , stagedLabel )),
212+ ghttp .VerifyRequest ("GET" , "/api/v0/deployed /products" ),
213+ ghttp .RespondWith (http .StatusOK , createDeployedProductResponse ( deployedGUID , deployedExpiryDate , deployedLabel )),
212214 ),
213215 )
214216
@@ -366,6 +368,30 @@ var _ = Describe("ExpiringLicenseService", func() {
366368 })
367369
368370 Describe ("edge cases" , func () {
371+ It ("correctly handles products with no license metadata" , func () {
372+ client .AppendHandlers (
373+ ghttp .CombineHandlers (
374+ ghttp .VerifyRequest ("GET" , "/api/v0/staged/products" ),
375+ ghttp .RespondWith (http .StatusOK , `[
376+ {
377+ "installation_name": "cf-no-license",
378+ "guid": "cf-no-license",
379+ "type": "cf",
380+ "product_version": "1.0-build.0",
381+ "label": "Product without license",
382+ "service_broker": false,
383+ "bosh_read_creds": false,
384+ "license_metadata": []
385+ }
386+ ]` ),
387+ ),
388+ )
389+
390+ licenses , err := service .ListExpiringLicenses ("30d" , true , false )
391+ Expect (err ).NotTo (HaveOccurred ())
392+ Expect (licenses ).To (HaveLen (0 ))
393+ })
394+
369395 It ("correctly handles products with multiple licenses (some expiring, some not)" , func () {
370396 expiringDate := formatDate (daysFromNow (20 ))
371397 futureDate := formatDate (daysFromNow (60 ))
@@ -406,30 +432,6 @@ var _ = Describe("ExpiringLicenseService", func() {
406432 expectSingleLicense (licenses , "cf-multiple-licenses" , expiringDate , "staged" )
407433 })
408434
409- It ("correctly handles products with no license metadata" , func () {
410- client .AppendHandlers (
411- ghttp .CombineHandlers (
412- ghttp .VerifyRequest ("GET" , "/api/v0/staged/products" ),
413- ghttp .RespondWith (http .StatusOK , `[
414- {
415- "installation_name": "cf-no-license",
416- "guid": "cf-no-license",
417- "type": "cf",
418- "product_version": "1.0-build.0",
419- "label": "Product without license",
420- "service_broker": false,
421- "bosh_read_creds": false,
422- "license_metadata": []
423- }
424- ]` ),
425- ),
426- )
427-
428- licenses , err := service .ListExpiringLicenses ("30d" , true , false )
429- Expect (err ).NotTo (HaveOccurred ())
430- Expect (licenses ).To (HaveLen (0 ))
431- })
432-
433435 It ("correctly handles licenses that have already expired" , func () {
434436 expiredDate := formatDate (daysFromNow (- 5 ))
435437 guid := "cf-expired-test"
@@ -471,15 +473,14 @@ var _ = Describe("ExpiringLicenseService", func() {
471473
472474 client .AppendHandlers (
473475 ghttp .CombineHandlers (
474- ghttp .VerifyRequest ("GET" , "/api/v0/deployed /products" ),
475- ghttp .RespondWith (http .StatusOK , createDeployedProductResponse (guid , deployedExpiryDate , label )),
476+ ghttp .VerifyRequest ("GET" , "/api/v0/staged /products" ),
477+ ghttp .RespondWith (http .StatusOK , createStagedProductResponse (guid , stagedExpiryDate , label )),
476478 ),
477479 )
478-
479480 client .AppendHandlers (
480481 ghttp .CombineHandlers (
481- ghttp .VerifyRequest ("GET" , "/api/v0/staged /products" ),
482- ghttp .RespondWith (http .StatusOK , createStagedProductResponse (guid , stagedExpiryDate , label )),
482+ ghttp .VerifyRequest ("GET" , "/api/v0/deployed /products" ),
483+ ghttp .RespondWith (http .StatusOK , createDeployedProductResponse (guid , deployedExpiryDate , label )),
483484 ),
484485 )
485486
@@ -517,15 +518,15 @@ var _ = Describe("ExpiringLicenseService", func() {
517518
518519 client .AppendHandlers (
519520 ghttp .CombineHandlers (
520- ghttp .VerifyRequest ("GET" , "/api/v0/deployed /products" ),
521- ghttp .RespondWith (http .StatusOK , createDeployedProductResponse (guid , expiryDate , label )),
521+ ghttp .VerifyRequest ("GET" , "/api/v0/staged /products" ),
522+ ghttp .RespondWith (http .StatusOK , createStagedProductResponse (guid , expiryDate , label )),
522523 ),
523524 )
524525
525526 client .AppendHandlers (
526527 ghttp .CombineHandlers (
527- ghttp .VerifyRequest ("GET" , "/api/v0/staged /products" ),
528- ghttp .RespondWith (http .StatusOK , createStagedProductResponse (guid , expiryDate , label )),
528+ ghttp .VerifyRequest ("GET" , "/api/v0/deployed /products" ),
529+ ghttp .RespondWith (http .StatusOK , createDeployedProductResponse (guid , expiryDate , label )),
529530 ),
530531 )
531532
@@ -536,7 +537,7 @@ var _ = Describe("ExpiringLicenseService", func() {
536537
537538 Expect (combinedLicense ).NotTo (BeNil ())
538539 Expect (combinedLicense .GUID ).To (Equal (guid ))
539- Expect (combinedLicense .ProductState ).To (Equal ([]string {"deployed " , "staged " }))
540+ Expect (combinedLicense .ProductState ).To (Equal ([]string {"staged " , "deployed " }))
540541 expectedStagedTime , _ := time .Parse ("2006-01-02" , expiryDate )
541542 Expect (combinedLicense .ExpiresAt ).To (Equal (expectedStagedTime ))
542543 })
0 commit comments