Skip to content

Commit 7b75b7e

Browse files
committed
Add missing fixtures
1 parent 60638e2 commit 7b75b7e

File tree

4 files changed

+54
-25
lines changed

4 files changed

+54
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,4 @@ gh-token.exe
7070

7171
# Test app keys
7272
*.pem
73+
!*.test.pem
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-----BEGIN PRIVATE KEY-----
2+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCL02nUZNMcAaOs
3+
J+L5qKErTjABtmS6CBgCbDbUN1u8Ds7hNMbYM/+P4W6OWbITnJD4V1sHpEj4/5u9
4+
tkqQt0x7IrXEAE2D+zWd4ntkdT7qDO3hpxj4/nPRakp7W2w9iLJNSeVLTjoVrnuQ
5+
GsGpR4NCu4PJOerLpmZXF6V+5IUyTnK2TC6NkXMl1YQ+plo0tmLjayOYOFyNhSk0
6+
2fNUo+Iwzse5XUqDncBkBKwHjwYnRVjB+fcn5WT88VWz4ejaXLD2DMcZmQmU+clP
7+
3r+AJddbk4cVHlGAW99uQ+c6M8M215wOg6cwpvXX20DY+Z4I56TIVq7WpHQyyrev
8+
noZ6O5/LAgMBAAECggEAA0arSpooJhZVvuFaXI4aZJja4BdlacRpx5jAeh1n7VKN
9+
f1JMvGEPgk/+VqB8XyBCd0cYr2emfAsFG59LRPO+e34XMyXsqwR2P6JAUNy8YiB2
10+
bFyNZbwUe5oZb6V3NkPfJZdvI2IMU1i4tWojEnPF/AjHsC3GtgnKiQzZSE1TX5fV
11+
E1PnG9u1x4FmcPBv6eL0mQ20MGYpt+l2kB1xSfFE72P4MYZ+xEAlbr94yA8ISVtp
12+
krh0xB77qU/kWnVw07DOneWhAJdRAhNRD+ZcU+UYfBzkvCNOprjiMYQxjjmmjouh
13+
RrkZd8AGnbCDe6SW2fhY6On0Cp8o/Wuz4NI58JfivQKBgQDAHjarGMeNanvxLDlx
14+
shY1xoLOxF/1ikhn+CFTW4sPZQOxOcsb/GmjwON1/4we2c8uZGdNd2tEPvDgfWhu
15+
XTDyOHU0JjsQEs0TsvUr1Jf1BVecFnu8dTC+sfUmNCBwwqyfp6KqDjrBmRVHRiRn
16+
L8rCQBDf3bk9ib2t0PNjk/v2DQKBgQC6UeXs3RpROxyQQ7Y05diyfPjL2V8tOzms
17+
t61NzH1LDv9snEyG7sB12b8sm0HIeka+uZkVdiqjZvbtXDAS2ZhlWBn3clr1Bmnf
18+
gdVIRQicXNb+aZRc2pBCGLCbcRNxGQYWRKNv3RFdDlG93ILwO1yXoY3Bie6yL+Vk
19+
eoj/lasPNwKBgQC3pupJqvlwBUAQL1+GgWBb7bUz5WN5/MP0p61r2xHXGJBsBbxU
20+
t3lg8c4/CZgwEbTNO2vJEQR4i9aGMzv2bJ2Sn0fjHzzMw7xJPYTDbooIzx+N9aw5
21+
XqnHUaTw7VmpkV+li4GjINEoKqe9p567CWPBR68Z4gHngtnQ4/MW2Os+rQKBgDGU
22+
2brOm9JCCLfbTQGGqMPWvd6BWfKPcCmmN1gcsrrmotIkRbkij9TMvTMBnd/bqjfW
23+
7AXqDC6vl8ZSYfiiLwvJBh/zLoFF06bGxhsVQ9VYX14Ueoa7Iuhz6Ytz69iM8DG8
24+
0kFScuxwgxAjPjTvlxRCyZZXPk3ssP6sHQjmqz7BAoGAHONxPaL5narYxGgySg49
25+
j3Ib9NROs2ys05dlTOZd0NYfkOsxtlNNncHGZ9NiikwtuJLeDibormsJhIgi8XXd
26+
kB8fa/kQXRWBNbD56ExVhSQiTPMNQXKXYXX2Ix/xcrHgzZzS0gAof7NKxwiuyhyi
27+
XeN8Q9ABpmAa5V1YvCP4qKM=
28+
-----END PRIVATE KEY-----

internal/generate_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestGenerate(t *testing.T) {
6767
defer httpmock.DeactivateAndReset()
6868

6969
// Read test key for base64 encoding
70-
keyBytes, err := os.ReadFile("fixtures/test-private-key.pem")
70+
keyBytes, err := os.ReadFile("fixtures/test-private-key.test.pem")
7171
assert.NoError(t, err)
7272
keyBase64 := base64.StdEncoding.EncodeToString(keyBytes)
7373

@@ -93,7 +93,7 @@ func TestGenerate(t *testing.T) {
9393
flags: map[string]interface{}{
9494
"app-id": "123456",
9595
"installation-id": "12345",
96-
"key": "fixtures/test-private-key.pem",
96+
"key": "fixtures/test-private-key.test.pem",
9797
"hostname": "api.github.com",
9898
"jwt-expiry": 10,
9999
"silent": true,
@@ -124,7 +124,7 @@ func TestGenerate(t *testing.T) {
124124
name: "successful_with_auto_installation_id",
125125
flags: map[string]interface{}{
126126
"app-id": "123456",
127-
"key": "fixtures/test-private-key.pem",
127+
"key": "fixtures/test-private-key.test.pem",
128128
"hostname": "api.github.com",
129129
"jwt-expiry": 10,
130130
"silent": true,
@@ -141,7 +141,7 @@ func TestGenerate(t *testing.T) {
141141
name: "successful_jwt_only",
142142
flags: map[string]interface{}{
143143
"app-id": "123456",
144-
"key": "fixtures/test-private-key.pem",
144+
"key": "fixtures/test-private-key.test.pem",
145145
"jwt": true,
146146
"jwt-expiry": 10,
147147
"silent": true,
@@ -161,7 +161,7 @@ func TestGenerate(t *testing.T) {
161161
name: "error_both_keys_specified",
162162
flags: map[string]interface{}{
163163
"app-id": "123456",
164-
"key": "fixtures/test-private-key.pem",
164+
"key": "fixtures/test-private-key.test.pem",
165165
"base64-key": keyBase64,
166166
},
167167
setupMocks: func() {},
@@ -189,7 +189,7 @@ func TestGenerate(t *testing.T) {
189189
name: "error_installation_not_found",
190190
flags: map[string]interface{}{
191191
"app-id": "123456",
192-
"key": "fixtures/test-private-key.pem",
192+
"key": "fixtures/test-private-key.test.pem",
193193
},
194194
setupMocks: func() {
195195
httpmock.RegisterResponder("GET", "https://api.github.com/app/installations?per_page=1",
@@ -202,7 +202,7 @@ func TestGenerate(t *testing.T) {
202202
flags: map[string]interface{}{
203203
"app-id": "123456",
204204
"installation-id": "12345",
205-
"key": "fixtures/test-private-key.pem",
205+
"key": "fixtures/test-private-key.test.pem",
206206
},
207207
setupMocks: func() {
208208
httpmock.RegisterResponder("POST", "https://api.github.com/app/installations/12345/access_tokens",
@@ -399,7 +399,7 @@ func TestGenerateAdvancedCases(t *testing.T) {
399399
setupTest: func() *cli.Context {
400400
return createTestContext(map[string]interface{}{
401401
"app-id": "123456",
402-
"key": "fixtures/test-private-key.pem",
402+
"key": "fixtures/test-private-key.test.pem",
403403
"jwt-expiry": 0, // Below minimum, should be adjusted to 10
404404
"jwt": true,
405405
"silent": true,
@@ -413,7 +413,7 @@ func TestGenerateAdvancedCases(t *testing.T) {
413413
setupTest: func() *cli.Context {
414414
return createTestContext(map[string]interface{}{
415415
"app-id": "123456",
416-
"key": "fixtures/test-private-key.pem",
416+
"key": "fixtures/test-private-key.test.pem",
417417
"jwt-expiry": 15, // Above maximum, should be adjusted to 10
418418
"jwt": true,
419419
"silent": true,
@@ -428,7 +428,7 @@ func TestGenerateAdvancedCases(t *testing.T) {
428428
return createTestContext(map[string]interface{}{
429429
"app-id": "123456",
430430
"installation-id": "12345",
431-
"key": "fixtures/test-private-key.pem",
431+
"key": "fixtures/test-private-key.test.pem",
432432
"hostname": "github.company.com", // Without /api/v3
433433
"silent": true,
434434
})
@@ -450,7 +450,7 @@ func TestGenerateAdvancedCases(t *testing.T) {
450450
return createTestContext(map[string]interface{}{
451451
"app-id": "123456",
452452
"installation-id": "12345",
453-
"key": "fixtures/test-private-key.pem",
453+
"key": "fixtures/test-private-key.test.pem",
454454
"hostname": "github.company.com/api/v3", // Already has /api/v3
455455
"silent": true,
456456
})
@@ -507,7 +507,7 @@ func TestGenerateWithOutputFormats(t *testing.T) {
507507
flags: map[string]interface{}{
508508
"app-id": "123456",
509509
"installation-id": "12345",
510-
"key": "fixtures/test-private-key.pem",
510+
"key": "fixtures/test-private-key.test.pem",
511511
"hostname": "api.github.com",
512512
"jwt-expiry": 10,
513513
"silent": false, // To test JSON output
@@ -522,7 +522,7 @@ func TestGenerateWithOutputFormats(t *testing.T) {
522522
flags: map[string]interface{}{
523523
"app-id": "123456",
524524
"installation-id": "12345",
525-
"key": "fixtures/test-private-key.pem",
525+
"key": "fixtures/test-private-key.test.pem",
526526
"hostname": "api.github.com",
527527
"jwt-expiry": 10,
528528
"token-only": true,
@@ -537,7 +537,7 @@ func TestGenerateWithOutputFormats(t *testing.T) {
537537
name: "jwt_output_format",
538538
flags: map[string]interface{}{
539539
"app-id": "123456",
540-
"key": "fixtures/test-private-key.pem",
540+
"key": "fixtures/test-private-key.test.pem",
541541
"jwt": true,
542542
"jwt-expiry": 10,
543543
"silent": false, // To test JWT output

internal/installations_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestInstallations(t *testing.T) {
5454
defer httpmock.DeactivateAndReset()
5555

5656
// Read test key for base64 encoding
57-
keyBytes, err := os.ReadFile("fixtures/test-private-key.pem")
57+
keyBytes, err := os.ReadFile("fixtures/test-private-key.test.pem")
5858
assert.NoError(t, err)
5959
keyBase64 := base64.StdEncoding.EncodeToString(keyBytes)
6060

@@ -92,7 +92,7 @@ func TestInstallations(t *testing.T) {
9292
name: "successful_list_installations_with_key_file",
9393
flags: map[string]interface{}{
9494
"app-id": "123456",
95-
"key": "fixtures/test-private-key.pem",
95+
"key": "fixtures/test-private-key.test.pem",
9696
"hostname": "api.github.com",
9797
},
9898
setupMocks: func() {
@@ -118,7 +118,7 @@ func TestInstallations(t *testing.T) {
118118
name: "successful_list_multiple_installations",
119119
flags: map[string]interface{}{
120120
"app-id": "123456",
121-
"key": "fixtures/test-private-key.pem",
121+
"key": "fixtures/test-private-key.test.pem",
122122
"hostname": "api.github.com",
123123
},
124124
setupMocks: func() {
@@ -131,7 +131,7 @@ func TestInstallations(t *testing.T) {
131131
name: "successful_empty_installations_list",
132132
flags: map[string]interface{}{
133133
"app-id": "123456",
134-
"key": "fixtures/test-private-key.pem",
134+
"key": "fixtures/test-private-key.test.pem",
135135
"hostname": "api.github.com",
136136
},
137137
setupMocks: func() {
@@ -144,7 +144,7 @@ func TestInstallations(t *testing.T) {
144144
name: "successful_with_custom_hostname_without_api_path",
145145
flags: map[string]interface{}{
146146
"app-id": "123456",
147-
"key": "fixtures/test-private-key.pem",
147+
"key": "fixtures/test-private-key.test.pem",
148148
"hostname": "github.company.com",
149149
},
150150
setupMocks: func() {
@@ -157,7 +157,7 @@ func TestInstallations(t *testing.T) {
157157
name: "successful_with_custom_hostname_with_api_path",
158158
flags: map[string]interface{}{
159159
"app-id": "123456",
160-
"key": "fixtures/test-private-key.pem",
160+
"key": "fixtures/test-private-key.test.pem",
161161
"hostname": "github.company.com/api/v3",
162162
},
163163
setupMocks: func() {
@@ -170,7 +170,7 @@ func TestInstallations(t *testing.T) {
170170
name: "successful_with_mixed_case_hostname",
171171
flags: map[string]interface{}{
172172
"app-id": "123456",
173-
"key": "fixtures/test-private-key.pem",
173+
"key": "fixtures/test-private-key.test.pem",
174174
"hostname": "GitHub.Company.COM",
175175
},
176176
setupMocks: func() {
@@ -191,7 +191,7 @@ func TestInstallations(t *testing.T) {
191191
name: "error_both_keys_specified",
192192
flags: map[string]interface{}{
193193
"app-id": "123456",
194-
"key": "fixtures/test-private-key.pem",
194+
"key": "fixtures/test-private-key.test.pem",
195195
"base64-key": keyBase64,
196196
},
197197
setupMocks: func() {},
@@ -219,7 +219,7 @@ func TestInstallations(t *testing.T) {
219219
name: "error_http_request_fails",
220220
flags: map[string]interface{}{
221221
"app-id": "123456",
222-
"key": "fixtures/test-private-key.pem",
222+
"key": "fixtures/test-private-key.test.pem",
223223
"hostname": "api.github.com",
224224
},
225225
setupMocks: func() {
@@ -232,7 +232,7 @@ func TestInstallations(t *testing.T) {
232232
name: "error_http_status_not_200",
233233
flags: map[string]interface{}{
234234
"app-id": "123456",
235-
"key": "fixtures/test-private-key.pem",
235+
"key": "fixtures/test-private-key.test.pem",
236236
"hostname": "api.github.com",
237237
},
238238
setupMocks: func() {
@@ -245,7 +245,7 @@ func TestInstallations(t *testing.T) {
245245
name: "error_invalid_json_response",
246246
flags: map[string]interface{}{
247247
"app-id": "123456",
248-
"key": "fixtures/test-private-key.pem",
248+
"key": "fixtures/test-private-key.test.pem",
249249
"hostname": "api.github.com",
250250
},
251251
setupMocks: func() {

0 commit comments

Comments
 (0)