@@ -13,34 +13,39 @@ import (
1313)
1414
1515func TestGetLatestLicense (t * testing.T ) {
16- sdkCustomerLicenseString := `apiVersion: kots.io/v1beta1
17- kind: License
18- metadata:
19- name: replicatedsdklicenseappcustomer0
20- spec:
21- licenseID: replicated-sdk-license-customer-0-license
22- licenseType: trial
23- customerName: Replicated SDK License App Customer 0
24- appSlug: replicated-sdk-license-app
25- channelID: replicated-sdk-license-app-nightly
26- channelName: Nightly
27- licenseSequence: 2
28- endpoint: http://replicated-app:3000
29- entitlements:
30- expires_at:
31- title: Expiration
32- description: License Expiration
33- value: '2050-01-01T01:23:46Z'
34- valueType: String
35- signature: {}
36- isNewKotsUiEnabled: true
37- isKotsInstallEnabled: true
38- `
16+ // sdkCustomerLicenseString := `apiVersion: kots.io/v1beta1
17+ // kind: License
18+ // metadata:
19+ // name: replicatedsdklicenseappcustomer0
20+ // spec:
21+ // licenseID: replicated-sdk-license-customer-0-license
22+ // licenseType: trial
23+ // customerName: Replicated SDK License App Customer 0
24+ // appSlug: replicated-sdk-license-app
25+ // channelID: replicated-sdk-license-app-nightly
26+ // channelName: Nightly
27+ // channels:
28+ // - channelID: replicated-sdk-license-app-nightly
29+ // channelName: Nightly
30+ // isDefault: true
31+ // endpoint: http://replicated-app:3000
32+ // licenseSequence: 2
33+ // endpoint: http://replicated-app:3000
34+ // entitlements:
35+ // expires_at:
36+ // title: Expiration
37+ // description: License Expiration
38+ // value: '2050-01-01T01:23:46Z'
39+ // valueType: String
40+ // signature: {}
41+ // isNewKotsUiEnabled: true
42+ // isKotsInstallEnabled: true
43+ // `
3944
40- sdkCustomerLicense , err := license .LoadLicenseFromBytes ([]byte (sdkCustomerLicenseString ))
41- if err != nil {
42- t .Fatalf ("failed to load license from bytes: %v" , err )
43- }
45+ // sdkCustomerLicense, err := license.LoadLicenseFromBytes([]byte(sdkCustomerLicenseString))
46+ // if err != nil {
47+ // t.Fatalf("failed to load license from bytes: %v", err)
48+ // }
4449
4550 type args struct {
4651 license * v1beta1.License
@@ -53,41 +58,41 @@ spec:
5358 want * license.LicenseData
5459 wantErr bool
5560 }{
56- {
57- name : "successful license sync" ,
58- args : args {
59- license : & v1beta1.License {
60- Spec : v1beta1.LicenseSpec {
61- LicenseID : "replicated-sdk-license-customer-0-license" ,
62- AppSlug : "replicated-sdk-license-app" ,
63- Endpoint : fmt .Sprintf ("http://%s:%d" , pact .Host , pact .Server .Port ),
64- },
65- },
66- },
67- pactInteraction : func () {
68- pact .
69- AddInteraction ().
70- Given ("License exists, is not archived, and app exists" ).
71- UponReceiving ("A request to get the latest license" ).
72- WithRequest (dsl.Request {
73- Method : http .MethodGet ,
74- Headers : dsl.MapMatcher {
75- "User-Agent" : dsl .String ("Replicated-SDK/v0.0.0-unknown" ),
76- "Authorization" : dsl .String (fmt .Sprintf ("Basic %s" , base64 .StdEncoding .EncodeToString ([]byte (fmt .Sprintf ("%s:%s" , "replicated-sdk-license-customer-0-license" , "replicated-sdk-license-customer-0-license" ))))),
77- },
78- Path : dsl .String (fmt .Sprintf ("/license/%s" , "replicated-sdk-license-app" )),
79- }).
80- WillRespondWith (dsl.Response {
81- Status : http .StatusOK ,
82- Body : dsl .Term (sdkCustomerLicenseString , sdkCustomerLicenseString ), // can't exact match because the signature changes
83- })
84- },
85- want : & license.LicenseData {
86- LicenseBytes : []byte (sdkCustomerLicenseString ),
87- License : sdkCustomerLicense ,
88- },
89- wantErr : false ,
90- },
61+ // {
62+ // name: "successful license sync",
63+ // args: args{
64+ // license: &v1beta1.License{
65+ // Spec: v1beta1.LicenseSpec{
66+ // LicenseID: "replicated-sdk-license-customer-0-license",
67+ // AppSlug: "replicated-sdk-license-app",
68+ // Endpoint: fmt.Sprintf("http://%s:%d", pact.Host, pact.Server.Port),
69+ // },
70+ // },
71+ // },
72+ // pactInteraction: func() {
73+ // pact.
74+ // AddInteraction().
75+ // Given("License exists, is not archived, and app exists").
76+ // UponReceiving("A request to get the latest license").
77+ // WithRequest(dsl.Request{
78+ // Method: http.MethodGet,
79+ // Headers: dsl.MapMatcher{
80+ // "User-Agent": dsl.String("Replicated-SDK/v0.0.0-unknown"),
81+ // "Authorization": dsl.String(fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", "replicated-sdk-license-customer-0-license", "replicated-sdk-license-customer-0-license"))))),
82+ // },
83+ // Path: dsl.String(fmt.Sprintf("/license/%s", "replicated-sdk-license-app")),
84+ // }).
85+ // WillRespondWith(dsl.Response{
86+ // Status: http.StatusOK,
87+ // Body: dsl.Term(sdkCustomerLicenseString, sdkCustomerLicenseString), // can't exact match because the signature changes
88+ // })
89+ // },
90+ // want: &license.LicenseData{
91+ // LicenseBytes: []byte(sdkCustomerLicenseString),
92+ // License: sdkCustomerLicense,
93+ // },
94+ // wantErr: false,
95+ // },
9196 {
9297 name : "no license found" ,
9398 args : args {
@@ -218,9 +223,11 @@ spec:
218223 if (err != nil ) != tt .wantErr {
219224 t .Errorf ("GetLatestLicense() error = %v, wantErr %v" , err , tt .wantErr )
220225 }
226+
221227 if ! reflect .DeepEqual (got , tt .want ) {
222228 t .Errorf ("GetLatestLicense() got = %v, want %v" , got , tt .want )
223229 }
230+
224231 return nil
225232 }); err != nil {
226233 t .Fatalf ("Error on Verify: %v" , err )
0 commit comments