@@ -45,26 +45,33 @@ func TestClient_Options(t *testing.T) {
4545 opts []OptFunc
4646 wantErr error
4747 }{
48- {
49- name : "Create new client" ,
50- opts : []OptFunc {WithInstllationID (installationID ), WithAppID (appID ), WithPrivateKey (kp .PrivateKey )},
51- },
5248 {
5349 name : "Create new client with proxy" ,
54- opts : []OptFunc {WithInstllationID (installationID ), WithAppID (appID ), WithPrivateKey (kp .PrivateKey ), WithProxyURL ((proxy ))},
50+ opts : []OptFunc {
51+ WithAppData (map [string ][]byte {
52+ KeyAppID : []byte (appID ),
53+ KeyAppInstallationID : []byte (installationID ),
54+ KeyAppPrivateKey : kp .PrivateKey ,
55+ }),
56+ WithProxyURL (proxy ),
57+ },
5558 },
5659 {
57- name : "Create new client with custom api url" ,
58- opts : []OptFunc {WithAppBaseURL (gitHubEnterpriseURL ), WithInstllationID (installationID ), WithAppID (appID ), WithPrivateKey (kp .PrivateKey )},
60+ name : "Create new client" ,
61+ opts : []OptFunc {WithAppData (map [string ][]byte {
62+ KeyAppID : []byte (appID ),
63+ KeyAppInstallationID : []byte (installationID ),
64+ KeyAppPrivateKey : kp .PrivateKey ,
65+ })},
5966 },
6067 {
61- name : "Create new client with app data " ,
68+ name : "Create new client with custom api url " ,
6269 opts : []OptFunc {WithAppData (map [string ][]byte {
63- AppIDKey : []byte (appID ),
64- AppInstallationIDKey : []byte (installationID ),
65- AppPrivateKey : kp . PrivateKey ,
66- } ,
67- )},
70+ KeyAppID : []byte (appID ),
71+ KeyAppInstallationID : []byte (installationID ),
72+ KeyAppBaseURL : [] byte ( gitHubEnterpriseURL ) ,
73+ KeyAppPrivateKey : kp . PrivateKey ,
74+ } )},
6875 },
6976 {
7077 name : "Create new client with empty data" ,
@@ -74,56 +81,56 @@ func TestClient_Options(t *testing.T) {
7481 {
7582 name : "Create new client with app data with missing AppID Key" ,
7683 opts : []OptFunc {WithAppData (map [string ][]byte {
77- AppInstallationIDKey : []byte (installationID ),
78- AppPrivateKey : kp .PrivateKey ,
84+ KeyAppInstallationID : []byte (installationID ),
85+ KeyAppPrivateKey : kp .PrivateKey ,
7986 },
8087 )},
8188 wantErr : errors .New ("app ID must be provided to use github app authentication" ),
8289 },
8390 {
8491 name : "Create new client with app data with missing AppInstallationID Key" ,
8592 opts : []OptFunc {WithAppData (map [string ][]byte {
86- AppIDKey : []byte ("123" ),
87- AppPrivateKey : kp .PrivateKey ,
93+ KeyAppID : []byte ("123" ),
94+ KeyAppPrivateKey : kp .PrivateKey ,
8895 },
8996 )},
9097 wantErr : errors .New ("app installation ID must be provided to use github app authentication" ),
9198 },
9299 {
93100 name : "Create new client with app data with missing private Key" ,
94101 opts : []OptFunc {WithAppData (map [string ][]byte {
95- AppIDKey : []byte (appID ),
96- AppInstallationIDKey : []byte (installationID ),
102+ KeyAppID : []byte (appID ),
103+ KeyAppInstallationID : []byte (installationID ),
97104 },
98105 )},
99106 wantErr : errors .New ("private key must be provided to use github app authentication" ),
100107 },
101108 {
102109 name : "Create new client with invalid appID in app data" ,
103110 opts : []OptFunc {WithAppData (map [string ][]byte {
104- AppIDKey : []byte ("abc" ),
105- AppInstallationIDKey : []byte (installationID ),
106- AppPrivateKey : kp .PrivateKey ,
111+ KeyAppID : []byte ("abc" ),
112+ KeyAppInstallationID : []byte (installationID ),
113+ KeyAppPrivateKey : kp .PrivateKey ,
107114 },
108115 )},
109116 wantErr : errors .New ("invalid app id, err: strconv.Atoi: parsing \" abc\" : invalid syntax" ),
110117 },
111118 {
112119 name : "Create new client with invalid installationID in app data" ,
113120 opts : []OptFunc {WithAppData (map [string ][]byte {
114- AppIDKey : []byte (appID ),
115- AppInstallationIDKey : []byte ("abc" ),
116- AppPrivateKey : kp .PrivateKey ,
121+ KeyAppID : []byte (appID ),
122+ KeyAppInstallationID : []byte ("abc" ),
123+ KeyAppPrivateKey : kp .PrivateKey ,
117124 },
118125 )},
119126 wantErr : errors .New ("invalid app installation id, err: strconv.Atoi: parsing \" abc\" : invalid syntax" ),
120127 },
121128 {
122129 name : "Create new client with invalid private key in app data" ,
123130 opts : []OptFunc {WithAppData (map [string ][]byte {
124- AppIDKey : []byte (appID ),
125- AppInstallationIDKey : []byte (installationID ),
126- AppPrivateKey : []byte (" " ),
131+ KeyAppID : []byte (appID ),
132+ KeyAppInstallationID : []byte (installationID ),
133+ KeyAppPrivateKey : []byte (" " ),
127134 },
128135 )},
129136 wantErr : errors .New ("could not parse private key: invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key" ),
@@ -230,7 +237,12 @@ func TestClient_GetCredentials(t *testing.T) {
230237 kp , err := ssh .GenerateKeyPair (ssh .RSA_4096 )
231238 g .Expect (err ).ToNot (HaveOccurred ())
232239 opts := []OptFunc {
233- WithAppBaseURL (srv .URL ), WithInstllationID ("123" ), WithAppID ("456" ), WithPrivateKey (kp .PrivateKey ),
240+ WithAppData (map [string ][]byte {
241+ KeyAppID : []byte ("123" ),
242+ KeyAppInstallationID : []byte ("456" ),
243+ KeyAppBaseURL : []byte (srv .URL ),
244+ KeyAppPrivateKey : kp .PrivateKey ,
245+ }),
234246 }
235247 opts = append (opts , tt .opts ... )
236248
0 commit comments