|
| 1 | +/* |
| 2 | + * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except |
| 5 | + * in compliance with the License. A copy of the License is located at |
| 6 | + * |
| 7 | + * http://aws.amazon.com/apache2.0 |
| 8 | + * |
| 9 | + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, |
| 10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 11 | + * specific language governing permissions and limitations under the License. |
| 12 | + */ |
| 13 | + |
| 14 | +package com.amazonaws.encryptionsdk.model; |
| 15 | + |
| 16 | +import static org.junit.Assert.assertEquals; |
| 17 | + |
| 18 | +import java.util.HashMap; |
| 19 | +import java.util.Map; |
| 20 | +import java.util.List; |
| 21 | +import java.util.ArrayList; |
| 22 | + |
| 23 | +import org.junit.Test; |
| 24 | + |
| 25 | +import com.amazonaws.encryptionsdk.CryptoAlgorithm; |
| 26 | +import com.amazonaws.encryptionsdk.model.DecryptionMaterialsRequest; |
| 27 | +import com.amazonaws.encryptionsdk.model.KeyBlob; |
| 28 | + |
| 29 | +public class DecryptionMaterialsRequestTest { |
| 30 | + @Test |
| 31 | + public void build() { |
| 32 | + CryptoAlgorithm alg = CryptoAlgorithm.ALG_AES_256_GCM_IV12_TAG16_HKDF_SHA256; |
| 33 | + Map<String, String> encryptionContext = new HashMap<String, String>(1); |
| 34 | + encryptionContext.put("DMR", "DecryptionMaterialsRequest Test"); |
| 35 | + List<KeyBlob> kbs = new ArrayList<KeyBlob>(); |
| 36 | + |
| 37 | + DecryptionMaterialsRequest request0 = DecryptionMaterialsRequest.newBuilder() |
| 38 | + .setAlgorithm(alg) |
| 39 | + .setEncryptionContext(encryptionContext) |
| 40 | + .setEncryptedDataKeys(kbs) |
| 41 | + .build(); |
| 42 | + |
| 43 | + DecryptionMaterialsRequest request1 = request0.toBuilder().build(); |
| 44 | + |
| 45 | + assertEquals(request0.getAlgorithm(), request1.getAlgorithm()); |
| 46 | + assertEquals(request0.getEncryptionContext().size(), request1.getEncryptionContext().size()); |
| 47 | + assertEquals(request0.getEncryptedDataKeys().size(), request1.getEncryptedDataKeys().size()); |
| 48 | + } |
| 49 | +} |
0 commit comments