Begin test update

This commit is contained in:
2024-04-08 00:24:46 -04:00
parent 8f0d1c64bd
commit 1a93a30b42
28 changed files with 559 additions and 78 deletions

View File

@@ -13,7 +13,9 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.mattrixwv.cipherstream.controller.CipherStreamControllerIntegrationTestBase;
import com.mattrixwv.cipherstream.utils.CipherInfoUtil;
import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
@@ -51,6 +53,27 @@ public class AdfgvxCipherControllerIntegrationTest extends CipherStreamControlle
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
}
@Test
public void testGetCipherInfo() throws Exception{
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.ADFGVX_CIPHER_NAME, CipherInfoUtil.ADFGVX_CIPHER_DESCRIPTION);
mockMvc.perform(get(url)
.header("X-Request-Id", requestId)
.header("X-Forwarded-For", "192.168.1.1"))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.ADFGVX_CIPHER_NAME))
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.ADFGVX_CIPHER_DESCRIPTION));
//Filter
super.verifyFilter(url);
//Controller
verify(adfgvxLogger, times(1)).info("Getting info for {}", CipherInfoUtil.ADFGVX_CIPHER_NAME);
//Cipher Aspect
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
}
@Test
public void testEncodeAdfgvx() throws Exception{
mockMvc.perform(get(url + "/encode")
@@ -65,7 +88,7 @@ public class AdfgvxCipherControllerIntegrationTest extends CipherStreamControlle
//Filter
super.verifyFilter(url + "/encode");
//Controller
verify(adfgvxLogger, times(1)).info("Encoding ADFGVX");
verify(adfgvxLogger, times(1)).info("Encoding {}", CipherInfoUtil.ADFGVX_CIPHER_NAME);
//Cipher Aspect
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
}
@@ -84,7 +107,7 @@ public class AdfgvxCipherControllerIntegrationTest extends CipherStreamControlle
//Filter
super.verifyFilter(url + "/decode");
//Controller
verify(adfgvxLogger, times(1)).info("Decoding ADFGVX");
verify(adfgvxLogger, times(1)).info("Decoding {}", CipherInfoUtil.ADFGVX_CIPHER_NAME);
//Cipher Aspect
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
}

View File

@@ -13,7 +13,9 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.mattrixwv.cipherstream.controller.CipherStreamControllerIntegrationTestBase;
import com.mattrixwv.cipherstream.utils.CipherInfoUtil;
import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
@@ -52,6 +54,26 @@ public class AdfgxCipherControllerIntegrationTest extends CipherStreamController
}
@Test
public void testGetCipherInfo() throws Exception{
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.ADFGX_CIPHER_NAME, CipherInfoUtil.ADFGX_CIPHER_DESCRIPTION);
mockMvc.perform(get(url)
.header("X-Request-Id", requestId)
.header("X-Forwarded-For", "192.168.1.1"))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.ADFGX_CIPHER_NAME))
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.ADFGX_CIPHER_DESCRIPTION));
//Filter
super.verifyFilter(url);
//Controller
verify(adfgxLogger, times(1)).info("Getting info for {}", CipherInfoUtil.ADFGX_CIPHER_NAME);
//Cipher Aspect
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
}
@Test
public void testEncodeAdfgx() throws Exception{
mockMvc.perform(get(url + "/encode")
@@ -66,7 +88,7 @@ public class AdfgxCipherControllerIntegrationTest extends CipherStreamController
//Filter
super.verifyFilter(url + "/encode");
//Controller
verify(adfgxLogger, times(1)).info("Encoding ADFGX");
verify(adfgxLogger, times(1)).info("Encoding {}", CipherInfoUtil.ADFGX_CIPHER_NAME);
//Cipher Aspect
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
}
@@ -85,7 +107,7 @@ public class AdfgxCipherControllerIntegrationTest extends CipherStreamController
//Filter
super.verifyFilter(url + "/decode");
//Controller
verify(adfgxLogger, times(1)).info("Decoding ADFGX");
verify(adfgxLogger, times(1)).info("Decoding {}", CipherInfoUtil.ADFGX_CIPHER_NAME);
//Cipher Aspect
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
}