Further fixes for unicode handling in manifests
We were occasionally trying to compute schema 2 version 1 signatures on the *unicode* representation, which was failing the signature check. This PR adds a new wrapper type called `Bytes`, which all manifests must take in, and which handles the unicodes vs encoded utf-8 stuff in a central location. This PR also adds a test for the manifest that was breaking in production.
This commit is contained in:
		
							parent
							
								
									05fa2bcbe0
								
							
						
					
					
						commit
						171c7e5238
					
				
					 28 changed files with 275 additions and 106 deletions
				
			
		|  | @ -682,7 +682,7 @@ class V2RegistryPushMixin(V2RegistryMixin): | |||
|       # a 202 response for success. | ||||
|       put_code = 400 if invalid else 202 | ||||
|       self.conduct('PUT', '/v2/%s/manifests/%s' % (repo_name, tag_name), | ||||
|                    data=manifest.bytes, expected_code=put_code, | ||||
|                    data=manifest.bytes.as_encoded_str(), expected_code=put_code, | ||||
|                    headers={'Content-Type': 'application/json'}, auth='jwt') | ||||
| 
 | ||||
|     return checksums, manifests | ||||
|  | @ -1628,7 +1628,7 @@ class V2RegistryTests(V2RegistryPullMixin, V2RegistryPushMixin, RegistryTestsMix | |||
|     manifest = builder.build(_JWK) | ||||
| 
 | ||||
|     self.conduct('PUT', '/v2/%s/manifests/%s' % (repo_name, tag_name), | ||||
|                  data=manifest.bytes, expected_code=415, | ||||
|                  data=manifest.bytes.as_encoded_str(), expected_code=415, | ||||
|                  headers={'Content-Type': 'application/vnd.docker.distribution.manifest.v2+json'}, | ||||
|                  auth='jwt') | ||||
| 
 | ||||
|  | @ -1662,7 +1662,7 @@ class V2RegistryTests(V2RegistryPullMixin, V2RegistryPushMixin, RegistryTestsMix | |||
|     manifest = builder.build(_JWK) | ||||
| 
 | ||||
|     self.conduct('PUT', '/v2/%s/manifests/%s' % (repo_name, tag_name), | ||||
|                  data=manifest.bytes, expected_code=415, | ||||
|                  data=manifest.bytes.as_encoded_str(), expected_code=415, | ||||
|                  headers={'Content-Type': 'application/vnd.oci.image.manifest.v1+json'}, | ||||
|                  auth='jwt') | ||||
| 
 | ||||
|  | @ -1682,7 +1682,7 @@ class V2RegistryTests(V2RegistryPullMixin, V2RegistryPushMixin, RegistryTestsMix | |||
|     manifest = builder.build(_JWK) | ||||
| 
 | ||||
|     response = self.conduct('PUT', '/v2/%s/manifests/%s' % (repo_name, tag_name), | ||||
|                             data=manifest.bytes, expected_code=400, | ||||
|                             data=manifest.bytes.as_encoded_str(), expected_code=400, | ||||
|                             headers={'Content-Type': 'application/json'}, auth='jwt') | ||||
|     self.assertEquals('MANIFEST_INVALID', response.json()['errors'][0]['code']) | ||||
| 
 | ||||
|  |  | |||
		Reference in a new issue