@@ -22,6 +22,7 @@ func TestPrivateRegistriesService_ListOrganizationPrivateRegistries(t *testing.T
2222
2323 mux .HandleFunc ("/orgs/o/private-registries" , func (w http.ResponseWriter , r * http.Request ) {
2424 testMethod (t , r , "GET" )
25+ testHeader (t , r , "X-Github-Api-Version" , "2026-03-10" )
2526 testFormValues (t , r , values {
2627 "page" : "2" ,
2728 })
@@ -52,7 +53,7 @@ func TestPrivateRegistriesService_ListOrganizationPrivateRegistries(t *testing.T
5253 Configurations : []* PrivateRegistry {
5354 {
5455 Name : Ptr ("MAVEN_REPOSITORY_SECRET" ),
55- RegistryType : Ptr ("maven_repository" ),
56+ RegistryType : Ptr (PrivateRegistryTypeMavenRepository ),
5657 Username : Ptr ("monalisa" ),
5758 CreatedAt : & Timestamp {time .Date (2019 , time .August , 10 , 14 , 59 , 22 , 0 , time .UTC )},
5859 UpdatedAt : & Timestamp {time .Date (2020 , time .January , 10 , 14 , 59 , 22 , 0 , time .UTC )},
@@ -90,11 +91,11 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry(t *testing.T
9091 client , mux , _ := setup (t )
9192
9293 input := & CreateOrganizationPrivateRegistry {
93- RegistryType : "maven_repository" ,
94- URL : "https://maven.pkg.github .com/OWNER/REPOSITORY" ,
94+ RegistryType : PrivateRegistryTypeMavenRepository ,
95+ URL : "https://example .com/OWNER/REPOSITORY" ,
9596 Username : Ptr ("monalisa" ),
96- EncryptedValue : "encrypted_value" ,
97- KeyID : "key_id" ,
97+ EncryptedValue : Ptr ( "encrypted_value" ) ,
98+ KeyID : Ptr ( "key_id" ) ,
9899 Visibility : PrivateRegistryVisibilitySelected ,
99100 SelectedRepositoryIDs : []int64 {1 , 2 , 3 },
100101 }
@@ -104,17 +105,20 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry(t *testing.T
104105 assertNilError (t , json .NewDecoder (r .Body ).Decode (& v ))
105106
106107 testMethod (t , r , "POST" )
108+ testHeader (t , r , "X-Github-Api-Version" , "2026-03-10" )
107109 if ! cmp .Equal (v , input ) {
108110 t .Errorf ("Request body = %+v, want %+v" , v , input )
109111 }
110112
113+ w .WriteHeader (http .StatusCreated )
111114 fmt .Fprint (w , `{
112115 "name": "MAVEN_REPOSITORY_SECRET",
113116 "registry_type": "maven_repository",
114117 "username": "monalisa",
118+ "visibility": "selected",
119+ "selected_repository_ids": [1, 2, 3],
115120 "created_at": "2019-08-10T14:59:22Z",
116- "updated_at": "2020-01-10T14:59:22Z",
117- "visibility": "selected"
121+ "updated_at": "2020-01-10T14:59:22Z"
118122}` )
119123 })
120124
@@ -125,12 +129,13 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry(t *testing.T
125129 }
126130
127131 want := & PrivateRegistry {
128- Name : Ptr ("MAVEN_REPOSITORY_SECRET" ),
129- RegistryType : Ptr ("maven_repository" ),
130- Username : Ptr ("monalisa" ),
131- CreatedAt : & Timestamp {time .Date (2019 , time .August , 10 , 14 , 59 , 22 , 0 , time .UTC )},
132- UpdatedAt : & Timestamp {time .Date (2020 , time .January , 10 , 14 , 59 , 22 , 0 , time .UTC )},
133- Visibility : Ptr (PrivateRegistryVisibilitySelected ),
132+ Name : Ptr ("MAVEN_REPOSITORY_SECRET" ),
133+ RegistryType : Ptr (PrivateRegistryTypeMavenRepository ),
134+ Username : Ptr ("monalisa" ),
135+ CreatedAt : & Timestamp {time .Date (2019 , time .August , 10 , 14 , 59 , 22 , 0 , time .UTC )},
136+ UpdatedAt : & Timestamp {time .Date (2020 , time .January , 10 , 14 , 59 , 22 , 0 , time .UTC )},
137+ Visibility : Ptr (PrivateRegistryVisibilitySelected ),
138+ SelectedRepositoryIDs : []int64 {1 , 2 , 3 },
134139 }
135140 if diff := cmp .Diff (want , privateRegistry ); diff != "" {
136141 t .Errorf ("PrivateRegistries.CreateOrganizationPrivateRegistries mismatch (-want +got):\\ n%v" , diff )
@@ -151,12 +156,155 @@ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry(t *testing.T
151156 })
152157}
153158
159+ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDC (t * testing.T ) {
160+ t .Parallel ()
161+ client , mux , _ := setup (t )
162+
163+ input := & CreateOrganizationPrivateRegistry {
164+ RegistryType : PrivateRegistryTypeMavenRepository ,
165+ URL : "https://example.com/maven" ,
166+ AuthType : Ptr ("oidc_azure" ),
167+ TenantID : Ptr ("my-tenant-id" ),
168+ ClientID : Ptr ("my-client-id" ),
169+ ReplacesBase : Ptr (true ),
170+ Visibility : PrivateRegistryVisibilitySelected ,
171+ SelectedRepositoryIDs : []int64 {1 , 2 , 3 },
172+ }
173+
174+ mux .HandleFunc ("/orgs/o/private-registries" , func (w http.ResponseWriter , r * http.Request ) {
175+ var v * CreateOrganizationPrivateRegistry
176+ assertNilError (t , json .NewDecoder (r .Body ).Decode (& v ))
177+
178+ testMethod (t , r , "POST" )
179+ testHeader (t , r , "X-Github-Api-Version" , "2026-03-10" )
180+ if ! cmp .Equal (v , input ) {
181+ t .Errorf ("Request body = %+v, want %+v" , v , input )
182+ }
183+
184+ w .WriteHeader (http .StatusCreated )
185+ fmt .Fprint (w , `{
186+ "name": "MAVEN_REPOSITORY_SECRET",
187+ "registry_type": "maven_repository",
188+ "visibility": "selected",
189+ "selected_repository_ids": [1, 2, 3],
190+ "created_at": "2019-08-10T14:59:22Z",
191+ "updated_at": "2020-01-10T14:59:22Z"
192+ }` )
193+ })
194+
195+ ctx := t .Context ()
196+ privateRegistry , _ , err := client .PrivateRegistries .CreateOrganizationPrivateRegistry (ctx , "o" , * input )
197+ if err != nil {
198+ t .Fatalf ("PrivateRegistries.CreateOrganizationPrivateRegistry (OIDC) returned error: %v" , err )
199+ }
200+
201+ want := & PrivateRegistry {
202+ Name : Ptr ("MAVEN_REPOSITORY_SECRET" ),
203+ RegistryType : Ptr (PrivateRegistryTypeMavenRepository ),
204+ CreatedAt : & Timestamp {time .Date (2019 , time .August , 10 , 14 , 59 , 22 , 0 , time .UTC )},
205+ UpdatedAt : & Timestamp {time .Date (2020 , time .January , 10 , 14 , 59 , 22 , 0 , time .UTC )},
206+ Visibility : Ptr (PrivateRegistryVisibilitySelected ),
207+ SelectedRepositoryIDs : []int64 {1 , 2 , 3 },
208+ }
209+ if diff := cmp .Diff (want , privateRegistry ); diff != "" {
210+ t .Errorf ("PrivateRegistries.CreateOrganizationPrivateRegistry (OIDC) mismatch (-want +got):\\ n%v" , diff )
211+ }
212+ }
213+
214+ func TestPrivateRegistries_UpdateOrganizationPrivateRegistry_OIDC (t * testing.T ) {
215+ t .Parallel ()
216+ client , mux , _ := setup (t )
217+
218+ input := & UpdateOrganizationPrivateRegistry {
219+ AuthType : Ptr ("oidc_aws" ),
220+ AWSRegion : Ptr ("us-east-1" ),
221+ AccountID : Ptr ("123456789012" ),
222+ RoleName : Ptr ("my-role" ),
223+ Domain : Ptr ("my-domain" ),
224+ DomainOwner : Ptr ("123456789012" ),
225+ Audience : Ptr ("example.com" ),
226+ Visibility : Ptr (PrivateRegistryVisibilitySelected ),
227+ }
228+
229+ mux .HandleFunc ("/orgs/o/private-registries/AWS_REGISTRY_SECRET" , func (w http.ResponseWriter , r * http.Request ) {
230+ var v * UpdateOrganizationPrivateRegistry
231+ assertNilError (t , json .NewDecoder (r .Body ).Decode (& v ))
232+
233+ testMethod (t , r , "PATCH" )
234+ testHeader (t , r , "X-Github-Api-Version" , "2026-03-10" )
235+ if ! cmp .Equal (v , input ) {
236+ t .Errorf ("Request body = %+v, want %+v" , v , input )
237+ }
238+
239+ w .WriteHeader (http .StatusNoContent )
240+ })
241+
242+ ctx := t .Context ()
243+ _ , err := client .PrivateRegistries .UpdateOrganizationPrivateRegistry (ctx , "o" , "AWS_REGISTRY_SECRET" , * input )
244+ if err != nil {
245+ t .Fatalf ("PrivateRegistries.UpdateOrganizationPrivateRegistry (OIDC) returned error: %v" , err )
246+ }
247+ }
248+
249+ func TestPrivateRegistriesService_CreateOrganizationPrivateRegistry_OIDCJFrog (t * testing.T ) {
250+ t .Parallel ()
251+ client , mux , _ := setup (t )
252+
253+ input := & CreateOrganizationPrivateRegistry {
254+ RegistryType : PrivateRegistryTypeNpmRegistry ,
255+ URL : "https://example.com/npm" ,
256+ AuthType : Ptr ("oidc_jfrog" ),
257+ JFrogOIDCProviderName : Ptr ("my-jfrog-provider" ),
258+ Audience : Ptr ("jfrog" ),
259+ IdentityMappingName : Ptr ("my-identity-mapping" ),
260+ Visibility : PrivateRegistryVisibilityPrivate ,
261+ }
262+
263+ mux .HandleFunc ("/orgs/o/private-registries" , func (w http.ResponseWriter , r * http.Request ) {
264+ var v * CreateOrganizationPrivateRegistry
265+ assertNilError (t , json .NewDecoder (r .Body ).Decode (& v ))
266+
267+ testMethod (t , r , "POST" )
268+ testHeader (t , r , "X-Github-Api-Version" , "2026-03-10" )
269+ if ! cmp .Equal (v , input ) {
270+ t .Errorf ("Request body = %+v, want %+v" , v , input )
271+ }
272+
273+ w .WriteHeader (http .StatusCreated )
274+ fmt .Fprint (w , `{
275+ "name": "NPM_REGISTRY_SECRET",
276+ "registry_type": "npm_registry",
277+ "visibility": "private",
278+ "created_at": "2019-08-10T14:59:22Z",
279+ "updated_at": "2020-01-10T14:59:22Z"
280+ }` )
281+ })
282+
283+ ctx := t .Context ()
284+ privateRegistry , _ , err := client .PrivateRegistries .CreateOrganizationPrivateRegistry (ctx , "o" , * input )
285+ if err != nil {
286+ t .Fatalf ("PrivateRegistries.CreateOrganizationPrivateRegistry (OIDC JFrog) returned error: %v" , err )
287+ }
288+
289+ want := & PrivateRegistry {
290+ Name : Ptr ("NPM_REGISTRY_SECRET" ),
291+ RegistryType : Ptr (PrivateRegistryTypeNpmRegistry ),
292+ CreatedAt : & Timestamp {time .Date (2019 , time .August , 10 , 14 , 59 , 22 , 0 , time .UTC )},
293+ UpdatedAt : & Timestamp {time .Date (2020 , time .January , 10 , 14 , 59 , 22 , 0 , time .UTC )},
294+ Visibility : Ptr (PrivateRegistryVisibilityPrivate ),
295+ }
296+ if diff := cmp .Diff (want , privateRegistry ); diff != "" {
297+ t .Errorf ("PrivateRegistries.CreateOrganizationPrivateRegistry (OIDC JFrog) mismatch (-want +got):\\ n%v" , diff )
298+ }
299+ }
300+
154301func TestPrivateRegistriesService_GetOrganizationPrivateRegistriesPublicKey (t * testing.T ) {
155302 t .Parallel ()
156303 client , mux , _ := setup (t )
157304
158305 mux .HandleFunc ("/orgs/o/private-registries/public-key" , func (w http.ResponseWriter , r * http.Request ) {
159306 testMethod (t , r , "GET" )
307+ testHeader (t , r , "X-Github-Api-Version" , "2026-03-10" )
160308 fmt .Fprint (w , `{
161309 "key_id": "0123456789",
162310 "key": "public_key"
@@ -197,6 +345,7 @@ func TestPrivateRegistriesService_GetOrganizationPrivateRegistry(t *testing.T) {
197345
198346 mux .HandleFunc ("/orgs/o/private-registries/MAVEN_REPOSITORY_SECRET" , func (w http.ResponseWriter , r * http.Request ) {
199347 testMethod (t , r , "GET" )
348+ testHeader (t , r , "X-Github-Api-Version" , "2026-03-10" )
200349 fmt .Fprint (w , `{
201350 "name": "MAVEN_REPOSITORY_SECRET",
202351 "registry_type": "maven_repository",
@@ -214,7 +363,7 @@ func TestPrivateRegistriesService_GetOrganizationPrivateRegistry(t *testing.T) {
214363
215364 want := & PrivateRegistry {
216365 Name : Ptr ("MAVEN_REPOSITORY_SECRET" ),
217- RegistryType : Ptr ("maven_repository" ),
366+ RegistryType : Ptr (PrivateRegistryTypeMavenRepository ),
218367 Username : Ptr ("monalisa" ),
219368 CreatedAt : & Timestamp {time .Date (2019 , time .August , 10 , 14 , 59 , 22 , 0 , time .UTC )},
220369 UpdatedAt : & Timestamp {time .Date (2020 , time .January , 10 , 14 , 59 , 22 , 0 , time .UTC )},
@@ -254,50 +403,28 @@ func TestPrivateRegistries_UpdateOrganizationPrivateRegistry(t *testing.T) {
254403 assertNilError (t , json .NewDecoder (r .Body ).Decode (& v ))
255404
256405 testMethod (t , r , "PATCH" )
406+ testHeader (t , r , "X-Github-Api-Version" , "2026-03-10" )
257407 if ! cmp .Equal (v , input ) {
258408 t .Errorf ("Request body = %+v, want %+v" , v , input )
259409 }
260410
261- fmt .Fprint (w , `{
262- "name": "MAVEN_REPOSITORY_SECRET",
263- "registry_type": "maven_repository",
264- "username": "monalisa",
265- "created_at": "2019-08-10T14:59:22Z",
266- "updated_at": "2020-01-10T14:59:22Z",
267- "visibility": "selected"
268- }` )
411+ w .WriteHeader (http .StatusNoContent )
269412 })
270413
271414 ctx := t .Context ()
272- privateRegistry , _ , err := client .PrivateRegistries .UpdateOrganizationPrivateRegistry (ctx , "o" , "MAVEN_REPOSITORY_SECRET" , * input )
415+ _ , err := client .PrivateRegistries .UpdateOrganizationPrivateRegistry (ctx , "o" , "MAVEN_REPOSITORY_SECRET" , * input )
273416 if err != nil {
274417 t .Fatalf ("PrivateRegistries.UpdateOrganizationPrivateRegistry returned error: %v" , err )
275418 }
276419
277- want := & PrivateRegistry {
278- Name : Ptr ("MAVEN_REPOSITORY_SECRET" ),
279- RegistryType : Ptr ("maven_repository" ),
280- Username : Ptr ("monalisa" ),
281- CreatedAt : & Timestamp {time .Date (2019 , time .August , 10 , 14 , 59 , 22 , 0 , time .UTC )},
282- UpdatedAt : & Timestamp {time .Date (2020 , time .January , 10 , 14 , 59 , 22 , 0 , time .UTC )},
283- Visibility : Ptr (PrivateRegistryVisibilitySelected ),
284- }
285- if diff := cmp .Diff (want , privateRegistry ); diff != "" {
286- t .Errorf ("PrivateRegistries.UpdateOrganizationPrivateRegistry mismatch (-want +got):\\ n%v" , diff )
287- }
288-
289420 const methodName = "UpdateOrganizationPrivateRegistry"
290421 testBadOptions (t , methodName , func () (err error ) {
291- _ , _ , err = client .PrivateRegistries .UpdateOrganizationPrivateRegistry (ctx , "\n " , "MAVEN_REPOSITORY_SECRET" , * input )
422+ _ , err = client .PrivateRegistries .UpdateOrganizationPrivateRegistry (ctx , "\n " , "MAVEN_REPOSITORY_SECRET" , * input )
292423 return err
293424 })
294425
295426 testNewRequestAndDoFailure (t , methodName , client , func () (* Response , error ) {
296- got , resp , err := client .PrivateRegistries .UpdateOrganizationPrivateRegistry (ctx , "o" , "MAVEN_REPOSITORY_SECRET" , * input )
297- if got != nil {
298- t .Errorf ("testNewRequestAndDoFailure %v = %#v, want nil" , methodName , got )
299- }
300- return resp , err
427+ return client .PrivateRegistries .UpdateOrganizationPrivateRegistry (ctx , "o" , "MAVEN_REPOSITORY_SECRET" , * input )
301428 })
302429}
303430
@@ -307,6 +434,7 @@ func TestPrivateRegistriesService_DeleteOrganizationPrivateRegistry(t *testing.T
307434
308435 mux .HandleFunc ("/orgs/o/private-registries/MAVEN_REPOSITORY_SECRET" , func (w http.ResponseWriter , r * http.Request ) {
309436 testMethod (t , r , "DELETE" )
437+ testHeader (t , r , "X-Github-Api-Version" , "2026-03-10" )
310438 w .WriteHeader (http .StatusNoContent )
311439 })
312440 ctx := t .Context ()
0 commit comments