List of commits:
Subject Hash Author Date (UTC)
Update test cases 351a1f00250e293ff49fd66c852a3bced9c296be mandas04 2019-01-31 15:21:06
Skipped testing during gradle build 37352f5b876e311a19a8b2aea5759c9c1be8f037 mandas04 2019-01-31 13:29:27
Adjust JaCoCo test coverage 3eca68000e279756223fc5d27accf3a12988ad1d mandas04 2019-01-31 13:17:55
update resttemplate configurations bd1da0c99a2f97c0f7ac1537121a093b7229cba5 mandas04 2019-01-31 13:10:04
Refactor test packages ddc3aae04e4ebceb21b5a421813be6e0cc7733ad mandas04 2019-01-31 11:46:57
Refactoring Test packages e916b5f3f15beb28f5a7373bc046cc81fb2b7630 mandas04 2019-01-31 04:36:10
Refactor DockerFile 90de083d4cb6128977b761994a02b244c8d3cf6c mandas04 2019-01-30 14:31:54
Refactor DockerFile cbf36a94f7e3d7cd6ca2c36279ec5d28886afc54 mandas04 2019-01-30 12:52:25
Liquibase setup for dev and prod separately 93cb8265755e2ceb14c45b1f99e8581aa93155fc mandas04 2019-01-30 12:41:48
Sanity test in dev: correct env variable name f0ecedb119b83f313b5a04e1affb4e1584790ce4 mandas04 2019-01-30 09:47:33
Refactor Jenkinsfile c853f0d754b0c4086e4fb02a0d4776e9865f77f5 mandas04 2019-01-30 09:16:41
Put hyphen in place of empty version c45822e737f1fc38a9498f5c3600de374762c588 mandas04 2019-01-30 09:14:51
Plot all applications (reference + reporting) in report 2c37a8767f97d63ac8c347f33fcc765d08ce1998 mandas04 2019-01-30 06:09:22
Setup liquibase for dev and prod separately 49dc85a8404833ebb7193a396a1ede16dafa32e5 mandas04 2019-01-30 05:44:31
Jenkins secret variable udpate 23ef9bc048d411e15da152aba1d87616bc7c0b97 mandas04 2019-01-30 05:03:31
User service reimplented as POST and DELETE method 8e08f92e52927c03152c7eca01b0549eb6608bf3 mandas04 2019-01-30 05:00:07
Adding wait for 2 mins before sanity test ebec65b19a1bd1cb36f0a8ac03d22c8893bf9123 mandas04 2019-01-29 15:42:27
Adding acceptance test criteria b38c915f4f14f13a73b3ae3945f791342ea31099 mandas04 2019-01-29 12:55:27
Fixed ordering of environments in report a76fd02548ee2550828c1084b233e2bdb5021312 mandas04 2019-01-29 11:39:26
Logger integration 27355b907d8c2e4d3a802bf596157807f723e240 mandas04 2019-01-29 09:01:37
Commit 351a1f00250e293ff49fd66c852a3bced9c296be - Update test cases
Author: mandas04
Author date (UTC): 2019-01-31 15:21
Committer name: mandas04
Committer date (UTC): 2019-01-31 15:21
Parent(s): 37352f5b876e311a19a8b2aea5759c9c1be8f037
Signing key:
Tree: 8393ad6d9d4a10fcb10dfce1cf0a9c7df79aff3b
File Lines added Lines deleted
Jenkinsfile 7 7
src/main/java/com/kingfisher/deployment/audit/config/security/SecurityConfig.java 4 3
src/main/java/com/kingfisher/deployment/audit/constant/ApplicationConstant.java 0 3
src/test/java/com/kingfisher/deployment/audit/test/smoke/ApplicationStatusControllerTest.java 3 1
src/test/java/com/kingfisher/deployment/audit/test/smoke/DeploymentAuditControllerTest.java 27 42
File Jenkinsfile changed (mode: 100644) (index 2c0e7d2..00fae08)
... ... pipeline{
12 12 { {
13 13 stage("Compile") { stage("Compile") {
14 14 steps { steps {
15 sh "sh ./gradlew compileJava"
15 sh "sh ./gradlew compileJava --stacktrace"
16 16 } }
17 17 } }
18 18
19 19 stage("Unit test") { stage("Unit test") {
20 20 steps { steps {
21 sh "sh ./gradlew test --tests com.kingfisher.deployment.audit.test.unit.suite.*"
21 sh "sh ./gradlew test --tests com.kingfisher.deployment.audit.test.unit.suite.* --stacktrace"
22 22 publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'build/reports/tests/test', reportFiles: 'index.html', reportName: 'Unit Test Report', reportTitles: 'Unit tests by Junit']) publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'build/reports/tests/test', reportFiles: 'index.html', reportName: 'Unit Test Report', reportTitles: 'Unit tests by Junit'])
23 23 } }
24 24 } }
25 25
26 26 stage('Setup dev DB instance') { stage('Setup dev DB instance') {
27 27 steps{ steps{
28 sh "sh ./gradlew update -PrunList=dev"
28 sh "sh ./gradlew update -PrunList=dev --stacktrace"
29 29 } }
30 30 } }
31 31
32 32 stage("Integration test with dev DB") { stage("Integration test with dev DB") {
33 33 steps { steps {
34 sh "sh ./gradlew test --tests com.kingfisher.deployment.audit.test.integration.suite.*"
34 sh "sh ./gradlew test --tests com.kingfisher.deployment.audit.test.integration.suite.* --stacktrace"
35 35 publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'build/reports/tests/test', reportFiles: 'index.html', reportName: 'Integration Test Report', reportTitles: 'Unit tests by Junit']) publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'build/reports/tests/test', reportFiles: 'index.html', reportName: 'Integration Test Report', reportTitles: 'Unit tests by Junit'])
36 36 } }
37 37 } }
 
... ... pipeline{
39 39 stage('Test Coverage') { stage('Test Coverage') {
40 40 steps{ steps{
41 41 // sh "sh ./gradlew check" // sh "sh ./gradlew check"
42 sh "sh ./gradlew jacocoTestReport"
42 sh "sh ./gradlew jacocoTestReport --stacktrace"
43 43 publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'build/reports/jacoco/test/html', reportFiles: 'index.html', reportName: 'Code Coverage Report', reportTitles: 'Code coverage by JaCoCo']) publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'build/reports/jacoco/test/html', reportFiles: 'index.html', reportName: 'Code Coverage Report', reportTitles: 'Code coverage by JaCoCo'])
44 44 } }
45 45 } }
 
... ... pipeline{
47 47 stage("Package") { stage("Package") {
48 48 steps { steps {
49 49 // sh "sh ./gradlew -Dskip.tests build" // sh "sh ./gradlew -Dskip.tests build"
50 sh "sh ./gradlew build -x test "
50 sh "sh ./gradlew build -x test --stacktrace"
51 51 } }
52 52 } }
53 53
 
... ... pipeline{
92 92
93 93 stage('Setup prod DB instance') { stage('Setup prod DB instance') {
94 94 steps{ steps{
95 sh "sh ./gradlew update -PrunList=prod"
95 sh "sh ./gradlew update -PrunList=prod --stacktrace"
96 96 } }
97 97 } }
98 98
File src/main/java/com/kingfisher/deployment/audit/config/security/SecurityConfig.java changed (mode: 100644) (index 22cb5e0..3b3106a)
... ... import org.springframework.security.config.annotation.web.configuration.WebSecur
13 13 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
14 14 import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;
15 15
16 import com.kingfisher.deployment.audit.constant.ApplicationConstant;
16 17 import com.kingfisher.deployment.audit.exception.model.DeploymentAuditException; import com.kingfisher.deployment.audit.exception.model.DeploymentAuditException;
17 18 import com.kingfisher.deployment.audit.security.CustomPasswordEncoder; import com.kingfisher.deployment.audit.security.CustomPasswordEncoder;
18 19
 
... ... public class SecurityConfig {
40 41 @Override @Override
41 42 protected void configure(HttpSecurity http) throws DeploymentAuditException { protected void configure(HttpSecurity http) throws DeploymentAuditException {
42 43 try { try {
43 http.csrf().disable().antMatcher("/v1/deployments/report**").authorizeRequests().anyRequest().hasRole("AUDITOR").and().httpBasic();
44 http.csrf().disable().antMatcher("/v1/deployments/report**").authorizeRequests().anyRequest().hasRole(ApplicationConstant.SECURITY_ROLE_AUDITOR).and().httpBasic();
44 45 } catch (Exception e) { } catch (Exception e) {
45 46 throw new DeploymentAuditException(e); throw new DeploymentAuditException(e);
46 47 } }
 
... ... public class SecurityConfig {
53 54 @Override @Override
54 55 protected void configure(HttpSecurity http) throws DeploymentAuditException { protected void configure(HttpSecurity http) throws DeploymentAuditException {
55 56 try { try {
56 http.csrf().disable().antMatcher("/v1/deployments**").authorizeRequests().anyRequest().hasRole("JENKINS").and().httpBasic();
57 http.csrf().disable().antMatcher("/v1/deployments**").authorizeRequests().anyRequest().hasRole(ApplicationConstant.SECURITY_ROLE_JENKINS).and().httpBasic();
57 58 } catch (Exception e) { } catch (Exception e) {
58 59 throw new DeploymentAuditException(e); throw new DeploymentAuditException(e);
59 60 } }
 
... ... public class SecurityConfig {
66 67 @Override @Override
67 68 protected void configure(HttpSecurity http) throws DeploymentAuditException { protected void configure(HttpSecurity http) throws DeploymentAuditException {
68 69 try { try {
69 http.csrf().disable().antMatcher("/v1/user/**").authorizeRequests().anyRequest().hasRole("ADMIN").and().httpBasic();
70 http.csrf().disable().antMatcher("/v1/user/**").authorizeRequests().anyRequest().hasRole(ApplicationConstant.SECURITY_ROLE_ADMIN).and().httpBasic();
70 71 } catch (Exception e) { } catch (Exception e) {
71 72 throw new DeploymentAuditException(e); throw new DeploymentAuditException(e);
72 73 } }
File src/main/java/com/kingfisher/deployment/audit/constant/ApplicationConstant.java changed (mode: 100644) (index ab8fcff..4bce51e)
... ... public class ApplicationConstant {
12 12 /** /**
13 13 * Constants * Constants
14 14 */ */
15 public static final String ROLE_ADMIN = "ADMIN";
16 public static final String ROLE_USER = "USER";
17 public static final String ROLE_JENKINS = "JENKINS";
18 15
19 16 public static final String FONT_CALIBRI = "Calibri"; public static final String FONT_CALIBRI = "Calibri";
20 17 public static final String FONT_WINGDINGS = "Wingdings"; public static final String FONT_WINGDINGS = "Wingdings";
File src/test/java/com/kingfisher/deployment/audit/test/smoke/ApplicationStatusControllerTest.java changed (mode: 100644) (index 791bd7c..affe802)
... ... import org.junit.runner.RunWith;
13 13 import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
14 14 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
15 15 import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
16 import org.springframework.test.context.ActiveProfiles;
16 17 import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
17 18 import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
18 19 import org.junit.contrib.java.lang.system.EnvironmentVariables; import org.junit.contrib.java.lang.system.EnvironmentVariables;
19 20
20 21 @RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
21 @SpringBootTest
22 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
23 @ActiveProfiles("dev")
22 24 @AutoConfigureMockMvc @AutoConfigureMockMvc
23 25 public class ApplicationStatusControllerTest { public class ApplicationStatusControllerTest {
24 26
File src/test/java/com/kingfisher/deployment/audit/test/smoke/DeploymentAuditControllerTest.java changed (mode: 100644) (index 3629826..c35dff1)
1 1 package com.kingfisher.deployment.audit.test.smoke; package com.kingfisher.deployment.audit.test.smoke;
2 2
3 3 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
4 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
5 4 import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
6 5 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
7 6
7 import java.util.ArrayList;
8 8 import java.util.Arrays; import java.util.Arrays;
9 import java.util.List;
9 10
10 import org.junit.FixMethodOrder;
11 11 import org.junit.Test; import org.junit.Test;
12 12 import org.junit.runner.RunWith; import org.junit.runner.RunWith;
13 import org.junit.runners.MethodSorters;
14 13 import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
15 14 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
16 15 import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
 
... ... import org.springframework.test.context.ActiveProfiles;
19 18 import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
20 19 import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
21 20 import com.kingfisher.deployment.audit.constant.ApplicationConstant; import com.kingfisher.deployment.audit.constant.ApplicationConstant;
22 import com.kingfisher.deployment.audit.model.User;
21 import com.kingfisher.deployment.audit.model.JenkinsDeploymentStatus;
22 import com.kingfisher.deployment.audit.model.ReportParam;
23 23 import com.kingfisher.deployment.audit.test.util.IntegrationTestUtil; import com.kingfisher.deployment.audit.test.util.IntegrationTestUtil;
24 24
25 25 @RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
26 26 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
27 27 @ActiveProfiles("dev") @ActiveProfiles("dev")
28 28 @AutoConfigureMockMvc @AutoConfigureMockMvc
29 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
30 29 public class DeploymentAuditControllerTest { public class DeploymentAuditControllerTest {
31 30
32 31 @Autowired @Autowired
33 32 private MockMvc mockMvc; private MockMvc mockMvc;
34 33
35 private static final String MOCK_ADMIN_USERNAME = "admin_user";
36 private static final String MOCK_ADMIN_PASSWORD = "admin_password";
37 private static final String TEST_USER_NAME = "test_user";
38 private static final String TEST_USER_NAME2 = "test_user2";
39 private static final String TEST_USER_PASSWORD = "test_user";
40 private static final String UNKOWN_USER_NAME = "unknown_user";
34 private static final String MOCK_JENKINS_USERNAME = "jenkins_user";
35 private static final String MOCK_JENKINS_PASSWORD = "jenkins_password";
36 private static final String MOCK_AUDITOR_USERNAME = "auditor_user";
37 private static final String MOCK_AUDITOR_PASSWORD = "auditor_password";
41 38
42 39 @Test @Test
43 @WithMockUser(username = MOCK_ADMIN_USERNAME, password = MOCK_ADMIN_PASSWORD, roles = ApplicationConstant.SECURITY_ROLE_ADMIN)
44 public void order1_testAddNewUser() throws Exception {
45 User user = new User(TEST_USER_NAME, TEST_USER_PASSWORD, Arrays.asList(new String[] { ApplicationConstant.SECURITY_USER_ROLE_ADMIN, ApplicationConstant.SECURITY_USER_ROLE_AUDITOR }));
46 this.mockMvc.perform(post("/v1/user").contentType(ApplicationConstant.CONTENT_TYPE_APPLICATION_JSON).content(IntegrationTestUtil.convertObjectToJsonString(user))).andDo(print()).andExpect(status().isCreated());
47 }
48
49 @Test
50 @WithMockUser(username = MOCK_ADMIN_USERNAME, password = MOCK_ADMIN_PASSWORD, roles = ApplicationConstant.SECURITY_ROLE_ADMIN)
51 public void order2_testUpdateExistingUser() throws Exception {
52 User user = new User(TEST_USER_NAME, TEST_USER_PASSWORD, Arrays.asList(new String[] { ApplicationConstant.SECURITY_USER_ROLE_ADMIN, ApplicationConstant.SECURITY_USER_ROLE_JENKINS }));
53 this.mockMvc.perform(post("/v1/user").contentType(ApplicationConstant.CONTENT_TYPE_APPLICATION_JSON).content(IntegrationTestUtil.convertObjectToJsonString(user))).andDo(print()).andExpect(status().isOk());
54 }
55
56 @Test
57 @WithMockUser(username = MOCK_ADMIN_USERNAME, password = MOCK_ADMIN_PASSWORD, roles = ApplicationConstant.SECURITY_ROLE_ADMIN)
58 public void order3_testUpdateNonExistingUser() throws Exception {
59 User user = new User(TEST_USER_NAME2, TEST_USER_PASSWORD, Arrays.asList(new String[] { ApplicationConstant.SECURITY_USER_ROLE_ADMIN, ApplicationConstant.SECURITY_USER_ROLE_JENKINS }));
60 this.mockMvc.perform(post("/v1/user").contentType(ApplicationConstant.CONTENT_TYPE_APPLICATION_JSON).content(IntegrationTestUtil.convertObjectToJsonString(user))).andDo(print()).andExpect(status().isCreated());
61 }
40 @WithMockUser(username = MOCK_JENKINS_USERNAME, password = MOCK_JENKINS_PASSWORD, roles = ApplicationConstant.SECURITY_ROLE_JENKINS)
41 public void testAdditionDeploymentRecord() throws Exception {
42 String applicationName = "Aisle_Gateway";
43 String environment = "Q";
44 String instanceName = "QIIBINST2";
45 String integrationServer = "SWEB_CNC1";
46 String deployedByUserName = "test user";
47 String deployedByUserId = "TEST_USER";
48 String createdByProcess = "auto test";
49 JenkinsDeploymentStatus jenkinsDeploymentStatus = new JenkinsDeploymentStatus(applicationName, environment, instanceName, integrationServer, deployedByUserName, deployedByUserId, createdByProcess);
50 List<JenkinsDeploymentStatus> JenkinsDeploymentStatuses = new ArrayList<>();
51 JenkinsDeploymentStatuses.add(jenkinsDeploymentStatus);
62 52
63 @Test
64 @WithMockUser(username = MOCK_ADMIN_USERNAME, password = MOCK_ADMIN_PASSWORD, roles = ApplicationConstant.SECURITY_ROLE_ADMIN)
65 public void order4_testRemoveExistingUser() throws Exception {
66 this.mockMvc.perform(delete("/v1/user").param("username", TEST_USER_NAME)).andDo(print()).andExpect(status().isAccepted());
53 this.mockMvc.perform(post("/v1/deployments").contentType(ApplicationConstant.CONTENT_TYPE_APPLICATION_JSON).content(IntegrationTestUtil.convertObjectToJsonString(JenkinsDeploymentStatuses))).andDo(print()).andExpect(status().isCreated());
67 54 } }
68 55
69 56 @Test @Test
70 @WithMockUser(username = MOCK_ADMIN_USERNAME, password = MOCK_ADMIN_PASSWORD, roles = ApplicationConstant.SECURITY_ROLE_ADMIN)
71 public void order5_testRemoveExistingUser2() throws Exception {
72 this.mockMvc.perform(delete("/v1/user").param("username", TEST_USER_NAME2)).andDo(print()).andExpect(status().isAccepted());
73 }
57 @WithMockUser(username = MOCK_AUDITOR_USERNAME, password = MOCK_AUDITOR_PASSWORD, roles = ApplicationConstant.SECURITY_ROLE_AUDITOR)
58 public void testGenerationDeploymentReport() throws Exception {
59 String referenceEnv = "Q";
60 List<String> reportingEnv = Arrays.asList(new String[] { "F", "V" });
61 ReportParam reportParam = new ReportParam(referenceEnv, reportingEnv);
74 62
75 @Test
76 @WithMockUser(username = MOCK_ADMIN_USERNAME, password = MOCK_ADMIN_PASSWORD, roles = ApplicationConstant.SECURITY_ROLE_ADMIN)
77 public void order6_testRemoveNonExistingUser() throws Exception {
78 this.mockMvc.perform(delete("/v1/user").param("username", UNKOWN_USER_NAME)).andDo(print()).andExpect(status().isNotFound());
63 this.mockMvc.perform(post("/v1/deployments/report").contentType(ApplicationConstant.CONTENT_TYPE_APPLICATION_JSON).content(IntegrationTestUtil.convertObjectToJsonString(reportParam))).andDo(print()).andExpect(status().isCreated());
79 64 } }
80 65 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/Sumangal-IN/deployment-audit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/Sumangal-IN/deployment-audit

Clone this repository using git:
git clone git://git.rocketgit.com/user/Sumangal-IN/deployment-audit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main