View Javadoc
1   /*
2    * Copyright (c) 2016 ingenieux Labs
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package br.com.ingenieux.mojo.beanstalk.bundle;
18  
19  import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
20  
21  import org.junit.Before;
22  import org.junit.Ignore;
23  import org.junit.Test;
24  
25  import static org.junit.Assert.assertEquals;
26  
27  @Ignore
28  public class RequestBuilderTest {
29  
30    private RequestSigner requestSigner;
31  
32    @Before
33    public void setUp() throws Exception {
34      //this.requestSigner = new RequestSigner(creds, );
35  
36      /*
37      requestSigner.applicationId = "readability-metrics-aws";
38  
39      //requestSigner.awsCredentials = creds;
40  
41      SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
42      dateTimeFormat.setTimeZone(new SimpleTimeZone(0, "UTC"));
43  
44      requestSigner.date = dateTimeFormat.parse("20121128T104956Z");
45  
46      //requestSigner.region = "us-east-1";
47      requestSigner.commitId = "cf9b20486b9b3bedc32276d8cee21e57db1987e2";
48      requestSigner.environmentName = "rm-aws";
49      */
50    }
51  
52    @Test
53    public void testEquality() throws Exception {
54      /*
55          assertEquals(
56              requestSigner.getPushUrl(),
57              "https://heygetarealkey:20121128T104956Z2d9d5c5609b3e5221759fc17ed487d4cf833a23a59d26747441fe9bbb056d488@git.elasticbeanstalk.us-east-1.amazonaws.com/v1/repos/726561646162696c6974792d6d6574726963732d617773/commitid/63663962323034383662396233626564633332323736643863656532316535376462313938376532/environment/726d2d617773");
58      */
59    }
60  
61    @Test
62    public void testCodeCommit() throws Exception {
63      CodeCommitRequestSigner signer =
64          new CodeCommitRequestSigner(
65              new DefaultAWSCredentialsProviderChain(), "ingenieux-image-blobs", RequestSignerBase.DATE_TIME_FORMAT.parse("20160105T031736Z"));
66  
67      String pushUrl = signer.getPushUrl();
68  
69      assertEquals(
70          pushUrl,
71          "https://0SB93DDYBE63367703R2:20160105T031736Z93cb4b090d8642fbe6772a5d1f8320bed5ec892195cafa6ce57d290d83b79b2a@git-codecommit.us-east-1.amazonaws.com/v1/repos/ingenieux-image-blobs");
72    }
73  }