Update cipher descriptions
This commit is contained in:
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,16 +28,20 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class AdfgvxCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private AdfgvxCipherController adfgvxCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.combination.AdfgvxCipherController")
|
||||
private Logger adfgvxLogger;
|
||||
//Fields
|
||||
private String url = "/adfgvx";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "AXgvdavfxgagfa afag^aaxdxfgdagda";
|
||||
private String keyword = "keyword";
|
||||
private String squareKeyword = "SquareKeyword";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/adfgvx";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "AXgvdavfxgagfa afag^aaxdxfgdagda";
|
||||
private static final String keyword = "keyword";
|
||||
private static final String squareKeyword = "SquareKeyword";
|
||||
private static final String adfgvxName = "adfgvxName";
|
||||
private static final String adfgvxDescription = "adfgvxDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -58,26 +63,29 @@ public class AdfgvxCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
encodedNode.put(CipherParameterUtil.SQUARE_KEYWORD, squareKeyword);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(adfgvxCipherController, "adfgvxName", adfgvxName);
|
||||
ReflectionTestUtils.setField(adfgvxCipherController, "adfgvxDescription", adfgvxDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.ADFGVX_CIPHER_NAME, CipherInfoUtil.ADFGVX_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(adfgvxName, adfgvxDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.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));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(adfgvxName))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(adfgvxDescription));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(adfgvxLogger, times(1)).info("Getting info for {}", CipherInfoUtil.ADFGVX_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ADFGVX_CIPHER_NAME);
|
||||
verify(adfgvxLogger, times(1)).info("Getting info for {}", adfgvxName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, adfgvxName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -96,8 +104,8 @@ public class AdfgvxCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(adfgvxLogger, times(1)).info("Encoding {}", CipherInfoUtil.ADFGVX_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ADFGVX_CIPHER_NAME);
|
||||
verify(adfgvxLogger, times(1)).info("Encoding {}", adfgvxName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, adfgvxName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -116,8 +124,8 @@ public class AdfgvxCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(adfgvxLogger, times(1)).info("Encoding {}", CipherInfoUtil.ADFGVX_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ADFGVX_CIPHER_NAME);
|
||||
verify(adfgvxLogger, times(1)).info("Encoding {}", adfgvxName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, adfgvxName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -136,8 +144,8 @@ public class AdfgvxCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(adfgvxLogger, times(1)).info("Decoding {}", CipherInfoUtil.ADFGVX_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ADFGVX_CIPHER_NAME);
|
||||
verify(adfgvxLogger, times(1)).info("Decoding {}", adfgvxName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, adfgvxName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -156,8 +164,8 @@ public class AdfgvxCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(adfgvxLogger, times(1)).info("Decoding {}", CipherInfoUtil.ADFGVX_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ADFGVX_CIPHER_NAME);
|
||||
verify(adfgvxLogger, times(1)).info("Decoding {}", adfgvxName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, adfgvxName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.combination;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,16 +25,24 @@ public class AdfgvxCipherControllerTest{
|
||||
private AdfgvxCipherController adfgvxCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String KEYWORD = CipherParameterUtil.KEYWORD;
|
||||
private static final String SQUARE_KEYWORD = CipherParameterUtil.SQUARE_KEYWORD;
|
||||
private static final String INPUT_STRING = "Message to-encode";
|
||||
private static final String OUTPUT_STRING = "AXgvdavfxgagfa afag-aaxdxfgdagda";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String adfgvxName = "adfgvxName";
|
||||
private static final String adfgvxDescription = "adfgvxDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(adfgvxCipherController, "adfgvxName", adfgvxName);
|
||||
ReflectionTestUtils.setField(adfgvxCipherController, "adfgvxDescription", adfgvxDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.ADFGVX_CIPHER_NAME, CipherInfoUtil.ADFGVX_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(adfgvxName, adfgvxDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = adfgvxCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,16 +28,20 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class AdfgxCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private AdfgxCipherController adfgxCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.combination.AdfgxCipherController")
|
||||
private Logger adfgxLogger;
|
||||
//Fields
|
||||
private String url = "/adfgx";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "AAgagadfagaxxd axdx^adafafxddgdf";
|
||||
private String keyword = "keyword";
|
||||
private String squareKeyword = "SquareKeyword";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/adfgx";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "AAgagadfagaxxd axdx^adafafxddgdf";
|
||||
private static final String keyword = "keyword";
|
||||
private static final String squareKeyword = "SquareKeyword";
|
||||
private static final String adfgxName = "adfgxName";
|
||||
private static final String adfgxDescription = "adfgxDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -58,26 +63,29 @@ public class AdfgxCipherControllerIntegrationTest extends CipherStreamController
|
||||
encodedNode.put(CipherParameterUtil.SQUARE_KEYWORD, squareKeyword);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(adfgxCipherController, "adfgxName", adfgxName);
|
||||
ReflectionTestUtils.setField(adfgxCipherController, "adfgxDescription", adfgxDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.ADFGX_CIPHER_NAME, CipherInfoUtil.ADFGX_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(adfgxName, adfgxDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.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));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(adfgxName))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(adfgxDescription));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(adfgxLogger, times(1)).info("Getting info for {}", CipherInfoUtil.ADFGX_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ADFGX_CIPHER_NAME);
|
||||
verify(adfgxLogger, times(1)).info("Getting info for {}", adfgxName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, adfgxName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -96,8 +104,8 @@ public class AdfgxCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(adfgxLogger, times(1)).info("Encoding {}", CipherInfoUtil.ADFGX_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ADFGX_CIPHER_NAME);
|
||||
verify(adfgxLogger, times(1)).info("Encoding {}", adfgxName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, adfgxName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -116,8 +124,8 @@ public class AdfgxCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(adfgxLogger, times(1)).info("Encoding {}", CipherInfoUtil.ADFGX_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ADFGX_CIPHER_NAME);
|
||||
verify(adfgxLogger, times(1)).info("Encoding {}", adfgxName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, adfgxName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -136,8 +144,8 @@ public class AdfgxCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(adfgxLogger, times(1)).info("Decoding {}", CipherInfoUtil.ADFGX_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ADFGX_CIPHER_NAME);
|
||||
verify(adfgxLogger, times(1)).info("Decoding {}", adfgxName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, adfgxName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -156,8 +164,8 @@ public class AdfgxCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(adfgxLogger, times(1)).info("Decoding {}", CipherInfoUtil.ADFGX_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ADFGX_CIPHER_NAME);
|
||||
verify(adfgxLogger, times(1)).info("Decoding {}", adfgxName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, adfgxName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.combination;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,16 +25,24 @@ public class AdfgxCipherControllerTest{
|
||||
private AdfgxCipherController adfgxCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String ADFGX_KEYWORD = CipherParameterUtil.KEYWORD;
|
||||
private static final String ADFGX_SQUARE_KEYWORD = CipherParameterUtil.SQUARE_KEYWORD;
|
||||
private static final String ADFGX_INPUT_STRING = "Message to^encode";
|
||||
private static final String ADFGX_OUTPUT_STRING = "AAgagadfagaxxd axdx^adafafxddgdf";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String adfgxName = "adfgxName";
|
||||
private static final String adfgxDescription = "adfgxDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(adfgxCipherController, "adfgxName", adfgxName);
|
||||
ReflectionTestUtils.setField(adfgxCipherController, "adfgxDescription", adfgxDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.ADFGX_CIPHER_NAME, CipherInfoUtil.ADFGX_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(adfgxName, adfgxDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = adfgxCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class AffineCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private AffineCipherController affineCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.monosubstitution.AffineCipherController")
|
||||
private Logger affineLogger;
|
||||
//Fields
|
||||
private String url = "/affine";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "Pbtthlb yz^burzwb";
|
||||
private int key1 = 5;
|
||||
private int key2 = 7;
|
||||
private static final String url = "/affine";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "Pbtthlb yz^burzwb";
|
||||
private static final int key1 = 5;
|
||||
private static final int key2 = 7;
|
||||
private static final String affineName = "affineCipherName";
|
||||
private static final String affineDescription = "affineCipherDescription";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
|
||||
|
||||
@@ -58,26 +63,29 @@ public class AffineCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
encodedNode.put(CipherParameterUtil.AFFINE_KEY_2, key2);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(affineCipherController, "affineName", affineName);
|
||||
ReflectionTestUtils.setField(affineCipherController, "affineDescription", affineDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.AFFINE_CIPHER_NAME, CipherInfoUtil.AFFINE_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(affineName, affineDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.AFFINE_CIPHER_DESCRIPTION))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.AFFINE_CIPHER_NAME));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(affineDescription))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(affineName));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(affineLogger, times(1)).info("Getting info for {}", CipherInfoUtil.AFFINE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.AFFINE_CIPHER_NAME);
|
||||
verify(affineLogger, times(1)).info("Getting info for {}", affineName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, affineName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -96,8 +104,8 @@ public class AffineCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(affineLogger, times(1)).info("Encoding {}", CipherInfoUtil.AFFINE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.AFFINE_CIPHER_NAME);
|
||||
verify(affineLogger, times(1)).info("Encoding {}", affineName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, affineName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -116,8 +124,8 @@ public class AffineCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(affineLogger, times(1)).info("Encoding {}", CipherInfoUtil.AFFINE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.AFFINE_CIPHER_NAME);
|
||||
verify(affineLogger, times(1)).info("Encoding {}", affineName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, affineName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -136,8 +144,8 @@ public class AffineCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(affineLogger, times(1)).info("Decoding {}", CipherInfoUtil.AFFINE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.AFFINE_CIPHER_NAME);
|
||||
verify(affineLogger, times(1)).info("Decoding {}", affineName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, affineName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -156,8 +164,8 @@ public class AffineCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(affineLogger, times(1)).info("Decoding {}", CipherInfoUtil.AFFINE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.AFFINE_CIPHER_NAME);
|
||||
verify(affineLogger, times(1)).info("Decoding {}", affineName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, affineName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.monosubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -28,11 +30,19 @@ public class AffineCipherControllerTest{
|
||||
private static final int AFFINE_KEY_1 = 5;
|
||||
private static final int AFFINE_KEY_2 = 7;
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String affineName = "affineCipherName";
|
||||
private static final String affineDescription = "affineCipherDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(affineCipherController, "affineName", affineName);
|
||||
ReflectionTestUtils.setField(affineCipherController, "affineDescription", affineDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.AFFINE_CIPHER_NAME, CipherInfoUtil.AFFINE_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(affineName, affineDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = affineCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,14 +28,18 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class AtbashCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private AtbashCipherController atbashController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.monosubstitution.AtbashCipherController")
|
||||
protected Logger atbashLogger;
|
||||
//Fields
|
||||
private String url = "/atbash";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "Nvhhztv gl^vmxlwv";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/atbash";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "Nvhhztv gl^vmxlwv";
|
||||
private static final String atbashName = "atbashName";
|
||||
private static final String atbashDescription = "atbashDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -52,26 +57,29 @@ public class AtbashCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
encodedNode.put(CipherParameterUtil.PRESERVE_SYMBOLS, true);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(atbashController, "atbashName", atbashName);
|
||||
ReflectionTestUtils.setField(atbashController, "atbashDescription", atbashDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.ATBASH_CIPHER_NAME, CipherInfoUtil.ATBASH_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(atbashName, atbashDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.ATBASH_CIPHER_DESCRIPTION))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.ATBASH_CIPHER_NAME));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(atbashDescription))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(atbashName));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(atbashLogger, times(1)).info("Getting info for {}", CipherInfoUtil.ATBASH_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ATBASH_CIPHER_NAME);
|
||||
verify(atbashLogger, times(1)).info("Getting info for {}", atbashName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, atbashName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -90,8 +98,8 @@ public class AtbashCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(atbashLogger, times(1)).info("Encoding {}", CipherInfoUtil.ATBASH_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ATBASH_CIPHER_NAME);
|
||||
verify(atbashLogger, times(1)).info("Encoding {}", atbashName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, atbashName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -110,8 +118,8 @@ public class AtbashCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(atbashLogger, times(1)).info("Encoding {}", CipherInfoUtil.ATBASH_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ATBASH_CIPHER_NAME);
|
||||
verify(atbashLogger, times(1)).info("Encoding {}", atbashName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, atbashName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -130,8 +138,8 @@ public class AtbashCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(atbashLogger, times(1)).info("Decoding {}", CipherInfoUtil.ATBASH_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ATBASH_CIPHER_NAME);
|
||||
verify(atbashLogger, times(1)).info("Decoding {}", atbashName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, atbashName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -150,8 +158,8 @@ public class AtbashCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(atbashLogger, times(1)).info("Decoding {}", CipherInfoUtil.ATBASH_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ATBASH_CIPHER_NAME);
|
||||
verify(atbashLogger, times(1)).info("Decoding {}", atbashName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, atbashName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.monosubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -22,11 +24,19 @@ public class AtbashCipherControllerTest{
|
||||
private AtbashCipherController atbashCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String ATBASH_INPUT_STRING = "Message to^encode";
|
||||
private static final String ATBASH_OUTPUT_STRING = "Nvhhztv gl^vmxlwv";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String atbashName = "atbashName";
|
||||
private static final String atbashDescription = "atbashDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(atbashCipherController, "atbashName", atbashName);
|
||||
ReflectionTestUtils.setField(atbashCipherController, "atbashDescription", atbashDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeAtbash(){
|
||||
ObjectNode cipherParams = generateParams(ATBASH_INPUT_STRING);
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class AutokeyCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private AutokeyCipherController autokeyCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.monosubstitution.AutokeyCipherController")
|
||||
protected Logger autokeyLogger;
|
||||
//Fields
|
||||
private String url = "/autokey";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "Wiqooxh fs^wfcuhx";
|
||||
private String keyword = "keyword";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/autokey";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "Wiqooxh fs^wfcuhx";
|
||||
private static final String keyword = "keyword";
|
||||
private static final String autokeyName = "autokeyName";
|
||||
private static final String autokeyDescription = "autokeyDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -55,26 +60,29 @@ public class AutokeyCipherControllerIntegrationTest extends CipherStreamControll
|
||||
encodedNode.put(CipherParameterUtil.KEYWORD, keyword);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(autokeyCipherController, "autokeyName", autokeyName);
|
||||
ReflectionTestUtils.setField(autokeyCipherController, "autokeyDescription", autokeyDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.AUTOKEY_CIPHER_NAME, CipherInfoUtil.AUTOKEY_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(autokeyName, autokeyDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.AUTOKEY_CIPHER_DESCRIPTION))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.AUTOKEY_CIPHER_NAME));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(autokeyDescription))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(autokeyName));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(autokeyLogger, times(1)).info("Getting info for {}", CipherInfoUtil.AUTOKEY_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.AUTOKEY_CIPHER_NAME);
|
||||
verify(autokeyLogger, times(1)).info("Getting info for {}", autokeyName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, autokeyName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -93,8 +101,8 @@ public class AutokeyCipherControllerIntegrationTest extends CipherStreamControll
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(autokeyLogger, times(1)).info("Encoding {}", CipherInfoUtil.AUTOKEY_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.AUTOKEY_CIPHER_NAME);
|
||||
verify(autokeyLogger, times(1)).info("Encoding {}", autokeyName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, autokeyName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -113,8 +121,8 @@ public class AutokeyCipherControllerIntegrationTest extends CipherStreamControll
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(autokeyLogger, times(1)).info("Encoding {}", CipherInfoUtil.AUTOKEY_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.AUTOKEY_CIPHER_NAME);
|
||||
verify(autokeyLogger, times(1)).info("Encoding {}", autokeyName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, autokeyName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -133,8 +141,8 @@ public class AutokeyCipherControllerIntegrationTest extends CipherStreamControll
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(autokeyLogger, times(1)).info("Decoding {}", CipherInfoUtil.AUTOKEY_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.AUTOKEY_CIPHER_NAME);
|
||||
verify(autokeyLogger, times(1)).info("Decoding {}", autokeyName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, autokeyName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -153,8 +161,8 @@ public class AutokeyCipherControllerIntegrationTest extends CipherStreamControll
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(autokeyLogger, times(1)).info("Decoding {}", CipherInfoUtil.AUTOKEY_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.AUTOKEY_CIPHER_NAME);
|
||||
verify(autokeyLogger, times(1)).info("Decoding {}", autokeyName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, autokeyName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.monosubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,15 +25,23 @@ public class AutokeyCipherControllerTest{
|
||||
private AutokeyCipherController autokeyCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String AUTOKEY_INPUT_STRING = "Message to^encode";
|
||||
private static final String AUTOKEY_OUTPUT_STRING = "Wiqooxh fs^wfcuhx";
|
||||
private static final String AUTOKEY_KEYWORD = CipherParameterUtil.KEYWORD;
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String autokeyName = "autokeyName";
|
||||
private static final String autokeyDescription = "autokeyDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(autokeyCipherController, "autokeyName", autokeyName);
|
||||
ReflectionTestUtils.setField(autokeyCipherController, "autokeyDescription", autokeyDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.AUTOKEY_CIPHER_NAME, CipherInfoUtil.AUTOKEY_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(autokeyName, autokeyDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = autokeyCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,14 +28,18 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class BaconianCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private BaconianCipherController baconianCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.monosubstitution.BaconianCipherController")
|
||||
protected Logger baconianLogger;
|
||||
//Fields
|
||||
private String url = "/baconian";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "ABABB aabaa baaab baaab aaaaa aabba aabaa baaba abbab aabaa abbaa aaaba abbab aaabb aabaa";
|
||||
private static final String url = "/baconian";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "ABABB aabaa baaab baaab aaaaa aabba aabaa baaba abbab aabaa abbaa aaaba abbab aaabb aabaa";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String baconianName = "baconianName";
|
||||
private static final String baconianDescription = "baconianDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -52,26 +57,29 @@ public class BaconianCipherControllerIntegrationTest extends CipherStreamControl
|
||||
encodedNode.put(CipherParameterUtil.PRESERVE_SYMBOLS, true);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString.replaceAll("[^a-zA-Z]", ""));
|
||||
|
||||
ReflectionTestUtils.setField(baconianCipherController, "baconianName", baconianName);
|
||||
ReflectionTestUtils.setField(baconianCipherController, "baconianDescription", baconianDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.BACONIAN_CIPHER_NAME, CipherInfoUtil.BACONIAN_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(baconianName, baconianDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.BACONIAN_CIPHER_DESCRIPTION))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.BACONIAN_CIPHER_NAME));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(baconianDescription))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(baconianName));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(baconianLogger, times(1)).info("Getting info for {}", CipherInfoUtil.BACONIAN_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BACONIAN_CIPHER_NAME);
|
||||
verify(baconianLogger, times(1)).info("Getting info for {}", baconianName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, baconianName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -90,8 +98,8 @@ public class BaconianCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(baconianLogger, times(1)).info("Encoding {}", CipherInfoUtil.BACONIAN_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BACONIAN_CIPHER_NAME);
|
||||
verify(baconianLogger, times(1)).info("Encoding {}", baconianName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, baconianName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -110,8 +118,8 @@ public class BaconianCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(baconianLogger, times(1)).info("Encoding {}", CipherInfoUtil.BACONIAN_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BACONIAN_CIPHER_NAME);
|
||||
verify(baconianLogger, times(1)).info("Encoding {}", baconianName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, baconianName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -130,8 +138,8 @@ public class BaconianCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(baconianLogger, times(1)).info("Decoding {}", CipherInfoUtil.BACONIAN_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BACONIAN_CIPHER_NAME);
|
||||
verify(baconianLogger, times(1)).info("Decoding {}", baconianName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, baconianName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -150,8 +158,8 @@ public class BaconianCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(baconianLogger, times(1)).info("Decoding {}", CipherInfoUtil.BACONIAN_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BACONIAN_CIPHER_NAME);
|
||||
verify(baconianLogger, times(1)).info("Decoding {}", baconianName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, baconianName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.monosubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,11 +29,20 @@ public class BaconianCipherControllerTest{
|
||||
private static final String BACONIAN_OUTPUT_STRING = "ABABB aabaa baaab baaab aaaaa aabba aabaa baaba abbab aabaa abbaa aaaba abbab aaabb aabaa";
|
||||
private static final String BACONIAN_DECODED_STRING = "Messagetoencode";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String baconianName = "baconianName";
|
||||
private static final String baconianDescription = "baconianDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(baconianCipherController, "baconianName", baconianName);
|
||||
ReflectionTestUtils.setField(baconianCipherController, "baconianDescription", baconianDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.BACONIAN_CIPHER_NAME, CipherInfoUtil.BACONIAN_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(baconianName, baconianDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = baconianCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class BaseXCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private BaseXCipherController baseXCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.monosubstitution.BaseXCipherController")
|
||||
protected Logger baseXLogger;
|
||||
//Fields
|
||||
private String url = "/basex";
|
||||
private String decodedString = "A+B@C d\te\nf";
|
||||
private String encodedString = "1000001 101011 1000010 1000000 1000011 100000 1100100 1001 1100101 1010 1100110";
|
||||
private int base = 2;
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/basex";
|
||||
private static final String decodedString = "A+B@C d\te\nf";
|
||||
private static final String encodedString = "1000001 101011 1000010 1000000 1000011 100000 1100100 1001 1100101 1010 1100110";
|
||||
private static final int base = 2;
|
||||
private static final String baseXName = "baseXName";
|
||||
private static final String baseXDescription = "baseXDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -55,26 +60,29 @@ public class BaseXCipherControllerIntegrationTest extends CipherStreamController
|
||||
encodedNode.put(CipherParameterUtil.BASE_X_BASE, base);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(baseXCipherController, "baseXName", baseXName);
|
||||
ReflectionTestUtils.setField(baseXCipherController, "baseXDescription", baseXDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.BASE_X_CIPHER_NAME, CipherInfoUtil.BASE_X_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(baseXName, baseXDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.BASE_X_CIPHER_DESCRIPTION))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.BASE_X_CIPHER_NAME));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(baseXDescription))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(baseXName));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(baseXLogger, times(1)).info("Getting info for {}", CipherInfoUtil.BASE_X_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BASE_X_CIPHER_NAME);
|
||||
verify(baseXLogger, times(1)).info("Getting info for {}", baseXName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, baseXName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -93,8 +101,8 @@ public class BaseXCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(baseXLogger, times(1)).info("Encoding {}", CipherInfoUtil.BASE_X_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BASE_X_CIPHER_NAME);
|
||||
verify(baseXLogger, times(1)).info("Encoding {}", baseXName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, baseXName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -113,8 +121,8 @@ public class BaseXCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(baseXLogger, times(1)).info("Encoding {}", CipherInfoUtil.BASE_X_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BASE_X_CIPHER_NAME);
|
||||
verify(baseXLogger, times(1)).info("Encoding {}", baseXName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, baseXName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -133,8 +141,8 @@ public class BaseXCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(baseXLogger, times(1)).info("Decoding {}", CipherInfoUtil.BASE_X_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BASE_X_CIPHER_NAME);
|
||||
verify(baseXLogger, times(1)).info("Decoding {}", baseXName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, baseXName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -153,8 +161,8 @@ public class BaseXCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(baseXLogger, times(1)).info("Decoding {}", CipherInfoUtil.BASE_X_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BASE_X_CIPHER_NAME);
|
||||
verify(baseXLogger, times(1)).info("Decoding {}", baseXName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, baseXName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.monosubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,15 +25,23 @@ public class BaseXCipherControllerTest{
|
||||
private BaseXCipherController baseXCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final int BASE_X_BASE = 2;
|
||||
private static final String BASE_X_INPUT_STRING = "A+B@C d\te\nf";
|
||||
private static final String BASE_X_OUTPUT_STRING = "1000001 101011 1000010 1000000 1000011 100000 1100100 1001 1100101 1010 1100110";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String baseXName = "baseXName";
|
||||
private static final String baseXDescription = "baseXDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(baseXCipherController, "baseXName", baseXName);
|
||||
ReflectionTestUtils.setField(baseXCipherController, "baseXDescription", baseXDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.BASE_X_CIPHER_NAME, CipherInfoUtil.BASE_X_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(baseXName, baseXDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = baseXCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class BeaufortCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private BeaufortCipherController beaufortCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.monosubstitution.BeaufortCipherController")
|
||||
protected Logger beaufortLogger;
|
||||
//Fields
|
||||
private String url = "/beaufort";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "Yageolz rq^ujmdag";
|
||||
private String keyword = "Ke*y word";
|
||||
private static final String url = "/beaufort";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "Yageolz rq^ujmdag";
|
||||
private static final String keyword = "Ke*y word";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String beaufortName = "beaufortName";
|
||||
private static final String beaufortDescription = "beaufortDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -55,26 +60,29 @@ public class BeaufortCipherControllerIntegrationTest extends CipherStreamControl
|
||||
encodedNode.put(CipherParameterUtil.KEYWORD, keyword);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(beaufortCipherController, "beaufortName", beaufortName);
|
||||
ReflectionTestUtils.setField(beaufortCipherController, "beaufortDescription", beaufortDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.BEAUFORT_CIPHER_NAME, CipherInfoUtil.BEAUFORT_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(beaufortName, beaufortDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.BEAUFORT_CIPHER_DESCRIPTION))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.BEAUFORT_CIPHER_NAME));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(beaufortDescription))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(beaufortName));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(beaufortLogger, times(1)).info("Getting info for {}", CipherInfoUtil.BEAUFORT_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BEAUFORT_CIPHER_NAME);
|
||||
verify(beaufortLogger, times(1)).info("Getting info for {}", beaufortName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, beaufortName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -93,8 +101,8 @@ public class BeaufortCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(beaufortLogger, times(1)).info("Encoding {}", CipherInfoUtil.BEAUFORT_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BEAUFORT_CIPHER_NAME);
|
||||
verify(beaufortLogger, times(1)).info("Encoding {}", beaufortName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, beaufortName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -113,8 +121,8 @@ public class BeaufortCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(beaufortLogger, times(1)).info("Encoding {}", CipherInfoUtil.BEAUFORT_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BEAUFORT_CIPHER_NAME);
|
||||
verify(beaufortLogger, times(1)).info("Encoding {}", beaufortName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, beaufortName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -133,8 +141,8 @@ public class BeaufortCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(beaufortLogger, times(1)).info("Decoding {}", CipherInfoUtil.BEAUFORT_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BEAUFORT_CIPHER_NAME);
|
||||
verify(beaufortLogger, times(1)).info("Decoding {}", beaufortName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, beaufortName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -153,8 +161,8 @@ public class BeaufortCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(beaufortLogger, times(1)).info("Decoding {}", CipherInfoUtil.BEAUFORT_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BEAUFORT_CIPHER_NAME);
|
||||
verify(beaufortLogger, times(1)).info("Decoding {}", beaufortName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, beaufortName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.monosubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,11 +29,19 @@ public class BeaufortCipherControllerTest{
|
||||
private static final String BEAUFORT_INPUT_STRING = "Message to^encode";
|
||||
private static final String BEAUFORT_OUTPUT_STRING = "Yageolz rq^ujmdag";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String beaufortName = "beaufortName";
|
||||
private static final String beaufortDescription = "beaufortDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(beaufortCipherController, "beaufortName", beaufortName);
|
||||
ReflectionTestUtils.setField(beaufortCipherController, "beaufortDescription", beaufortDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.BEAUFORT_CIPHER_NAME, CipherInfoUtil.BEAUFORT_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(beaufortName, beaufortDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = beaufortCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class CaesarCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private CaesarCipherController caesarCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.monosubstitution.CaesarCipherController")
|
||||
protected Logger caesarLogger;
|
||||
//Fields
|
||||
private String url = "/caesar";
|
||||
private String decodedString = "The quick brown fox jumps over - the lazy dog";
|
||||
private String encodedString = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
|
||||
private int shiftAmount = 23;
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/caesar";
|
||||
private static final String decodedString = "The quick brown fox jumps over - the lazy dog";
|
||||
private static final String encodedString = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
|
||||
private static final int shiftAmount = 23;
|
||||
private static final String caesarName = "caesarName";
|
||||
private static final String caesarDescription = "caesarDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -55,26 +60,29 @@ public class CaesarCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
encodedNode.put(CipherParameterUtil.CAESAR_SHIFT_AMOUNT, shiftAmount);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(caesarCipherController, "caesarName", caesarName);
|
||||
ReflectionTestUtils.setField(caesarCipherController, "caesarDescription", caesarDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.CAESAR_CIPHER_NAME, CipherInfoUtil.CAESAR_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(caesarName, caesarDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.CAESAR_CIPHER_DESCRIPTION))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.CAESAR_CIPHER_NAME));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(caesarDescription))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(caesarName));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(caesarLogger, times(1)).info("Getting info for {}", CipherInfoUtil.CAESAR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.CAESAR_CIPHER_NAME);
|
||||
verify(caesarLogger, times(1)).info("Getting info for {}", caesarName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, caesarName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -93,8 +101,8 @@ public class CaesarCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(caesarLogger, times(1)).info("Encoding {}", CipherInfoUtil.CAESAR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.CAESAR_CIPHER_NAME);
|
||||
verify(caesarLogger, times(1)).info("Encoding {}", caesarName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, caesarName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -113,8 +121,8 @@ public class CaesarCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(caesarLogger, times(1)).info("Encoding {}", CipherInfoUtil.CAESAR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.CAESAR_CIPHER_NAME);
|
||||
verify(caesarLogger, times(1)).info("Encoding {}", caesarName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, caesarName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -133,8 +141,8 @@ public class CaesarCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(caesarLogger, times(1)).info("Decoding {}", CipherInfoUtil.CAESAR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.CAESAR_CIPHER_NAME);
|
||||
verify(caesarLogger, times(1)).info("Decoding {}", caesarName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, caesarName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -153,8 +161,8 @@ public class CaesarCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(caesarLogger, times(1)).info("Decoding {}", CipherInfoUtil.CAESAR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.CAESAR_CIPHER_NAME);
|
||||
verify(caesarLogger, times(1)).info("Decoding {}", caesarName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, caesarName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.monosubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,11 +29,19 @@ public class CaesarCipherControllerTest{
|
||||
private static final String CAESAR_OUTPUT_STRING = "Qeb nrfzh yoltk clu grjmp lsbo - qeb ixwv ald";
|
||||
private static final int CAESAR_SHIFT_AMOUNT = 23;
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String caesarName = "caesarName";
|
||||
private static final String caesarDescription = "caesarDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(caesarCipherController, "caesarName", caesarName);
|
||||
ReflectionTestUtils.setField(caesarCipherController, "caesarDescription", caesarDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.CAESAR_CIPHER_NAME, CipherInfoUtil.CAESAR_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(caesarName, caesarDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = caesarCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class OneTimePadCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private OneTimePadCipherController oneTimePadCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.monosubstitution.OneTimePadCipherController")
|
||||
protected Logger oneTimePadLogger;
|
||||
//Fields
|
||||
private String url = "/oneTimePad";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "Wiqooxh mv^egkgws";
|
||||
private String keyword = "keywordThatIsTotallyRandom";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/oneTimePad";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "Wiqooxh mv^egkgws";
|
||||
private static final String keyword = "keywordThatIsTotallyRandom";
|
||||
private static final String oneTimePadName = "oneTimePadName";
|
||||
private static final String oneTimePadDescription = "oneTimePadDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -55,26 +60,29 @@ public class OneTimePadCipherControllerIntegrationTest extends CipherStreamContr
|
||||
encodedNode.put(CipherParameterUtil.KEYWORD, keyword);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(oneTimePadCipherController, "oneTimePadName", oneTimePadName);
|
||||
ReflectionTestUtils.setField(oneTimePadCipherController, "oneTimePadDescription", oneTimePadDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME, CipherInfoUtil.ONE_TIME_PAD_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(oneTimePadName, oneTimePadDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.ONE_TIME_PAD_CIPHER_DESCRIPTION))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(oneTimePadDescription))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(oneTimePadName));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(oneTimePadLogger, times(1)).info("Getting info for {}", CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME);
|
||||
verify(oneTimePadLogger, times(1)).info("Getting info for {}", oneTimePadName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, oneTimePadName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -93,8 +101,8 @@ public class OneTimePadCipherControllerIntegrationTest extends CipherStreamContr
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(oneTimePadLogger, times(1)).info("Encoding {}", CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME);
|
||||
verify(oneTimePadLogger, times(1)).info("Encoding {}", oneTimePadName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, oneTimePadName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -113,8 +121,8 @@ public class OneTimePadCipherControllerIntegrationTest extends CipherStreamContr
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(oneTimePadLogger, times(1)).info("Encoding {}", CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME);
|
||||
verify(oneTimePadLogger, times(1)).info("Encoding {}", oneTimePadName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, oneTimePadName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -133,8 +141,8 @@ public class OneTimePadCipherControllerIntegrationTest extends CipherStreamContr
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(oneTimePadLogger, times(1)).info("Decoding {}", CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME);
|
||||
verify(oneTimePadLogger, times(1)).info("Decoding {}", oneTimePadName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, oneTimePadName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -153,8 +161,8 @@ public class OneTimePadCipherControllerIntegrationTest extends CipherStreamContr
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(oneTimePadLogger, times(1)).info("Decoding {}", CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME);
|
||||
verify(oneTimePadLogger, times(1)).info("Decoding {}", oneTimePadName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, oneTimePadName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.monosubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,15 +25,23 @@ public class OneTimePadCipherControllerTest{
|
||||
private OneTimePadCipherController oneTimePadCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String ONE_TIME_PAD_KEYWORD = "keywordThatIsTotallyRandom";
|
||||
private static final String ONE_TIME_PAD_INPUT_STRING = "Message to^encode";
|
||||
private static final String ONE_TIME_PAD_OUTPUT_STRING = "Wiqooxh mv^egkgws";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String oneTimePadName = "oneTimePadName";
|
||||
private static final String oneTimePadDescription = "oneTimePadDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(oneTimePadCipherController, "oneTimePadName", oneTimePadName);
|
||||
ReflectionTestUtils.setField(oneTimePadCipherController, "oneTimePadDescription", oneTimePadDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.ONE_TIME_PAD_CIPHER_NAME, CipherInfoUtil.ONE_TIME_PAD_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(oneTimePadName, oneTimePadDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = oneTimePadCipherController.getCipherInfo();
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -28,15 +29,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class PortaCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private PortaCipherController portaCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.monosubstitution.PortaCipherController")
|
||||
protected Logger portaLogger;
|
||||
//Fields
|
||||
private String url = "/porta";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "Rtghuos bm^qcwgrw";
|
||||
private String keyword = "keyword";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/porta";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "Rtghuos bm^qcwgrw";
|
||||
private static final String keyword = "keyword";
|
||||
private static final String portaName = "portaName";
|
||||
private static final String portaDescription = "portaDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -56,26 +61,29 @@ public class PortaCipherControllerIntegrationTest extends CipherStreamController
|
||||
encodedNode.put(CipherParameterUtil.KEYWORD, keyword);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(portaCipherController, "portaName", portaName);
|
||||
ReflectionTestUtils.setField(portaCipherController, "portaDescription", portaDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.PORTA_CIPHER_NAME, CipherInfoUtil.PORTA_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(portaName, portaDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.PORTA_CIPHER_DESCRIPTION))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.PORTA_CIPHER_NAME));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(portaDescription))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(portaName));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(portaLogger, times(1)).info("Getting info for {}", CipherInfoUtil.PORTA_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.PORTA_CIPHER_NAME);
|
||||
verify(portaLogger, times(1)).info("Getting info for {}", portaName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, portaName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -98,8 +106,8 @@ public class PortaCipherControllerIntegrationTest extends CipherStreamController
|
||||
verify(mdc, times(1)).put("url", url + "/encode");
|
||||
verify(mdc, times(1)).clear();
|
||||
//Controller
|
||||
verify(portaLogger, times(1)).info("Encoding {}", CipherInfoUtil.PORTA_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.PORTA_CIPHER_NAME);
|
||||
verify(portaLogger, times(1)).info("Encoding {}", portaName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, portaName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -118,8 +126,8 @@ public class PortaCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(portaLogger, times(1)).info("Encoding {}", CipherInfoUtil.PORTA_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.PORTA_CIPHER_NAME);
|
||||
verify(portaLogger, times(1)).info("Encoding {}", portaName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, portaName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -142,8 +150,8 @@ public class PortaCipherControllerIntegrationTest extends CipherStreamController
|
||||
verify(mdc, times(1)).put("url", url + "/decode");
|
||||
verify(mdc, times(1)).clear();
|
||||
//Controller
|
||||
verify(portaLogger, times(1)).info("Decoding {}", CipherInfoUtil.PORTA_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.PORTA_CIPHER_NAME);
|
||||
verify(portaLogger, times(1)).info("Decoding {}", portaName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, portaName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -162,8 +170,8 @@ public class PortaCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(portaLogger, times(1)).info("Decoding {}", CipherInfoUtil.PORTA_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.PORTA_CIPHER_NAME);
|
||||
verify(portaLogger, times(1)).info("Decoding {}", portaName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, portaName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.monosubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,15 +25,23 @@ public class PortaCipherControllerTest{
|
||||
private PortaCipherController portaCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String PORTA_KEYWORD = CipherParameterUtil.KEYWORD;
|
||||
private static final String PORTA_INPUT_STRING = "Message to^encode";
|
||||
private static final String PORTA_OUTPUT_STRING = "Rtghuos bm^qcwgrw";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String portaName = "portaName";
|
||||
private static final String portaDescription = "portaDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(portaCipherController, "portaName", portaName);
|
||||
ReflectionTestUtils.setField(portaCipherController, "portaDescription", portaDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.PORTA_CIPHER_NAME, CipherInfoUtil.PORTA_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(portaName, portaDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = portaCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class SubstitutionCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private SubstitutionCipherController substitutionCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.monosubstitution.SubstitutionCipherController")
|
||||
protected Logger substitutionLogger;
|
||||
//Fields
|
||||
private String url = "/substitution";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "Oguucig vq^gpeqfg";
|
||||
private String keyword = "cdefghijklmnopqrstuvwxyzab";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/substitution";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "Oguucig vq^gpeqfg";
|
||||
private static final String keyword = "cdefghijklmnopqrstuvwxyzab";
|
||||
private static final String substitutionName = "substitutionName";
|
||||
private static final String substitutionDescription = "substitutionDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -55,26 +60,29 @@ public class SubstitutionCipherControllerIntegrationTest extends CipherStreamCon
|
||||
encodedNode.put(CipherParameterUtil.KEYWORD, keyword);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(substitutionCipherController, "substitutionName", substitutionName);
|
||||
ReflectionTestUtils.setField(substitutionCipherController, "substitutionDescription", substitutionDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.SUBSTITUTION_CIPHER_NAME, CipherInfoUtil.SUBSTITUTION_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(substitutionName, substitutionDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.SUBSTITUTION_CIPHER_DESCRIPTION))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.SUBSTITUTION_CIPHER_NAME));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(substitutionDescription))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(substitutionName));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(substitutionLogger, times(1)).info("Getting info for {}", CipherInfoUtil.SUBSTITUTION_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.SUBSTITUTION_CIPHER_NAME);
|
||||
verify(substitutionLogger, times(1)).info("Getting info for {}", substitutionName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, substitutionName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -93,8 +101,8 @@ public class SubstitutionCipherControllerIntegrationTest extends CipherStreamCon
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(substitutionLogger, times(1)).info("Encoding {}", CipherInfoUtil.SUBSTITUTION_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.SUBSTITUTION_CIPHER_NAME);
|
||||
verify(substitutionLogger, times(1)).info("Encoding {}", substitutionName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, substitutionName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -113,8 +121,8 @@ public class SubstitutionCipherControllerIntegrationTest extends CipherStreamCon
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(substitutionLogger, times(1)).info("Encoding {}", CipherInfoUtil.SUBSTITUTION_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.SUBSTITUTION_CIPHER_NAME);
|
||||
verify(substitutionLogger, times(1)).info("Encoding {}", substitutionName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, substitutionName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -133,8 +141,8 @@ public class SubstitutionCipherControllerIntegrationTest extends CipherStreamCon
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(substitutionLogger, times(1)).info("Decoding {}", CipherInfoUtil.SUBSTITUTION_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.SUBSTITUTION_CIPHER_NAME);
|
||||
verify(substitutionLogger, times(1)).info("Decoding {}", substitutionName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, substitutionName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -153,8 +161,8 @@ public class SubstitutionCipherControllerIntegrationTest extends CipherStreamCon
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(substitutionLogger, times(1)).info("Decoding {}", CipherInfoUtil.SUBSTITUTION_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.SUBSTITUTION_CIPHER_NAME);
|
||||
verify(substitutionLogger, times(1)).info("Decoding {}", substitutionName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, substitutionName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.monosubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,15 +25,23 @@ public class SubstitutionCipherControllerTest{
|
||||
private SubstitutionCipherController substitutionCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String SUBSTITUTION_KEYWORD = "cdefghijklmnopqrstuvwxyzab9876543210";
|
||||
private static final String SUBSTITUTION_INPUT_STRING = "Message to&encode 123";
|
||||
private static final String SUBSTITUTION_OUTPUT_STRING = "Oguucig vq&gpeqfg 876";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String substitutionName = "substitutionName";
|
||||
private static final String substitutionDescription = "substitutionDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(substitutionCipherController, "substitutionName", substitutionName);
|
||||
ReflectionTestUtils.setField(substitutionCipherController, "substitutionDescription", substitutionDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.SUBSTITUTION_CIPHER_NAME, CipherInfoUtil.SUBSTITUTION_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(substitutionName, substitutionDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = substitutionCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class VigenereCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private VigenereCipherController vigenereCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.monosubstitution.VigenereCipherController")
|
||||
protected Logger vigenereLogger;
|
||||
//Fields
|
||||
private String url = "/vigenere";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "Wiqooxh ds^cjqfgo";
|
||||
private String keyword = "keyword";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/vigenere";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "Wiqooxh ds^cjqfgo";
|
||||
private static final String keyword = "keyword";
|
||||
private static final String vigenereName = "vigenereName";
|
||||
private static final String vigenereDescription = "vigenereDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -55,26 +60,29 @@ public class VigenereCipherControllerIntegrationTest extends CipherStreamControl
|
||||
encodedNode.put(CipherParameterUtil.KEYWORD, keyword);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(vigenereCipherController, "vigenereName", vigenereName);
|
||||
ReflectionTestUtils.setField(vigenereCipherController, "vigenereDescription", vigenereDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.VIGENERE_CIPHER_NAME, CipherInfoUtil.VIGENERE_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(vigenereName, vigenereDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.VIGENERE_CIPHER_DESCRIPTION))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.VIGENERE_CIPHER_NAME));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(vigenereDescription))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(vigenereName));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(vigenereLogger, times(1)).info("Getting info for {}", CipherInfoUtil.VIGENERE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.VIGENERE_CIPHER_NAME);
|
||||
verify(vigenereLogger, times(1)).info("Getting info for {}", vigenereName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, vigenereName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -93,8 +101,8 @@ public class VigenereCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(vigenereLogger, times(1)).info("Encoding {}", CipherInfoUtil.VIGENERE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.VIGENERE_CIPHER_NAME);
|
||||
verify(vigenereLogger, times(1)).info("Encoding {}", vigenereName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, vigenereName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -113,8 +121,8 @@ public class VigenereCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(vigenereLogger, times(1)).info("Encoding {}", CipherInfoUtil.VIGENERE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.VIGENERE_CIPHER_NAME);
|
||||
verify(vigenereLogger, times(1)).info("Encoding {}", vigenereName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, vigenereName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -133,8 +141,8 @@ public class VigenereCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(vigenereLogger, times(1)).info("Decoding {}", CipherInfoUtil.VIGENERE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.VIGENERE_CIPHER_NAME);
|
||||
verify(vigenereLogger, times(1)).info("Decoding {}", vigenereName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, vigenereName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -153,8 +161,8 @@ public class VigenereCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(vigenereLogger, times(1)).info("Decoding {}", CipherInfoUtil.VIGENERE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.VIGENERE_CIPHER_NAME);
|
||||
verify(vigenereLogger, times(1)).info("Decoding {}", vigenereName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, vigenereName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.monosubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,15 +25,23 @@ public class VigenereCipherControllerTest{
|
||||
private VigenereCipherController vigenereCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String VIGENERE_KEYWORD = CipherParameterUtil.KEYWORD;
|
||||
private static final String VIGENERE_INPUT_STRING = "Message to^encode";
|
||||
private static final String VIGENERE_OUTPUT_STRING = "Wiqooxh ds^cjqfgo";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String vigenereName = "vigenereName";
|
||||
private static final String vigenereDescription = "vigenereDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(vigenereCipherController, "vigenereName", vigenereName);
|
||||
ReflectionTestUtils.setField(vigenereCipherController, "vigenereDescription", vigenereDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.VIGENERE_CIPHER_NAME, CipherInfoUtil.VIGENERE_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(vigenereName, vigenereDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = vigenereCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class BifidCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private BifidCipherController bifidCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.polysubstitution.BifidCipherController")
|
||||
protected Logger bifidLogger;
|
||||
//Fields
|
||||
private String url = "/bifid";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "Mqaokne kc^vdodzd";
|
||||
private String keyword = "keyword";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/bifid";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "Mqaokne kc^vdodzd";
|
||||
private static final String keyword = "keyword";
|
||||
private static final String bifidName = "bifidName";
|
||||
private static final String bifidDescription = "bifidDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -55,26 +60,29 @@ public class BifidCipherControllerIntegrationTest extends CipherStreamController
|
||||
encodedNode.put(CipherParameterUtil.KEYWORD, keyword);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(bifidCipherController, "bifidName", bifidName);
|
||||
ReflectionTestUtils.setField(bifidCipherController, "bifidDescription", bifidDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.BIFID_CIPHER_NAME, CipherInfoUtil.BIFID_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(bifidName, bifidDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.BIFID_CIPHER_NAME))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.BIFID_CIPHER_DESCRIPTION));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(bifidName))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(bifidDescription));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(bifidLogger, times(1)).info("Getting info for {}", CipherInfoUtil.BIFID_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BIFID_CIPHER_NAME);
|
||||
verify(bifidLogger, times(1)).info("Getting info for {}", bifidName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, bifidName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -93,8 +101,8 @@ public class BifidCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(bifidLogger, times(1)).info("Encoding {}", CipherInfoUtil.BIFID_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BIFID_CIPHER_NAME);
|
||||
verify(bifidLogger, times(1)).info("Encoding {}", bifidName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, bifidName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -113,8 +121,8 @@ public class BifidCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(bifidLogger, times(1)).info("Encoding {}", CipherInfoUtil.BIFID_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BIFID_CIPHER_NAME);
|
||||
verify(bifidLogger, times(1)).info("Encoding {}", bifidName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, bifidName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -133,8 +141,8 @@ public class BifidCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(bifidLogger, times(1)).info("Decoding {}", CipherInfoUtil.BIFID_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BIFID_CIPHER_NAME);
|
||||
verify(bifidLogger, times(1)).info("Decoding {}", bifidName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, bifidName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -153,8 +161,8 @@ public class BifidCipherControllerIntegrationTest extends CipherStreamController
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(bifidLogger, times(1)).info("Decoding {}", CipherInfoUtil.BIFID_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.BIFID_CIPHER_NAME);
|
||||
verify(bifidLogger, times(1)).info("Decoding {}", bifidName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, bifidName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.polysubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,15 +25,23 @@ public class BifidCipherControllerTest{
|
||||
private BifidCipherController bifidCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String BIFID_INPUT_STRING = "Message to^encode";
|
||||
private static final String BIFID_OUTPUT_STRING = "Mqaokne kc^vdodzd";
|
||||
private static final String BIFID_KEYWORD = CipherParameterUtil.KEYWORD;
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String bifidName = "bifidName";
|
||||
private static final String bifidDescription = "bifidDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(bifidCipherController, "bifidName", bifidName);
|
||||
ReflectionTestUtils.setField(bifidCipherController, "bifidDescription", bifidDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.BIFID_CIPHER_NAME, CipherInfoUtil.BIFID_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(bifidName, bifidDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = bifidCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class ColumnarCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private ColumnarCipherController columnarCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.polysubstitution.ColumnarCipherController")
|
||||
protected Logger columnarLogger;
|
||||
//Fields
|
||||
private String url = "/columnar";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "Edeomte ac^gosnse";
|
||||
private String keyword = "keyword";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/columnar";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "Edeomte ac^gosnse";
|
||||
private static final String keyword = "keyword";
|
||||
private static final String columnarName = "columnarName";
|
||||
private static final String columnarDescription = "columnarDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -55,26 +60,29 @@ public class ColumnarCipherControllerIntegrationTest extends CipherStreamControl
|
||||
encodedNode.put(CipherParameterUtil.KEYWORD, keyword);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(columnarCipherController, "columnarName", columnarName);
|
||||
ReflectionTestUtils.setField(columnarCipherController, "columnarDescription", columnarDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.COLUMNAR_CIPHER_NAME, CipherInfoUtil.COLUMNAR_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(columnarName, columnarDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.COLUMNAR_CIPHER_NAME))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.COLUMNAR_CIPHER_DESCRIPTION));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(columnarName))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(columnarDescription));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(columnarLogger, times(1)).info("Getting info for {}", CipherInfoUtil.COLUMNAR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.COLUMNAR_CIPHER_NAME);
|
||||
verify(columnarLogger, times(1)).info("Getting info for {}", columnarName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, columnarName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -93,8 +101,8 @@ public class ColumnarCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(columnarLogger, times(1)).info("Encoding {}", CipherInfoUtil.COLUMNAR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.COLUMNAR_CIPHER_NAME);
|
||||
verify(columnarLogger, times(1)).info("Encoding {}", columnarName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, columnarName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -113,8 +121,8 @@ public class ColumnarCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(columnarLogger, times(1)).info("Encoding {}", CipherInfoUtil.COLUMNAR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.COLUMNAR_CIPHER_NAME);
|
||||
verify(columnarLogger, times(1)).info("Encoding {}", columnarName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, columnarName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -133,8 +141,8 @@ public class ColumnarCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(columnarLogger, times(1)).info("Decoding {}", CipherInfoUtil.COLUMNAR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.COLUMNAR_CIPHER_NAME);
|
||||
verify(columnarLogger, times(1)).info("Decoding {}", columnarName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, columnarName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -153,8 +161,8 @@ public class ColumnarCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(columnarLogger, times(1)).info("Decoding {}", CipherInfoUtil.COLUMNAR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.COLUMNAR_CIPHER_NAME);
|
||||
verify(columnarLogger, times(1)).info("Decoding {}", columnarName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, columnarName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.polysubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,15 +25,24 @@ public class ColumnarCipherControllerTest{
|
||||
private ColumnarCipherController columnarCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String COLUMNAR_INPUT_STRING = "Message to*encode";
|
||||
private static final String COLUMNAR_OUTPUT_STRING = "Edeomte ac*gosnse";
|
||||
private static final String COLUMNAR_KEYWORD = CipherParameterUtil.KEYWORD;
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String columnarName = "columnarName";
|
||||
private static final String columnarDescription = "columnarDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(columnarCipherController, "columnarName", columnarName);
|
||||
ReflectionTestUtils.setField(columnarCipherController, "columnarDescription", columnarDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.COLUMNAR_CIPHER_NAME, CipherInfoUtil.COLUMNAR_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(columnarName, columnarDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = columnarCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class HillCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private HillCipherController hillCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.polysubstitution.HillCipherController")
|
||||
protected Logger hillLogger;
|
||||
//Fields
|
||||
private String url = "/hill";
|
||||
private String decodedString = "Message to^encoded";
|
||||
private String encodedString = "Mgkeqge ul^ikhisplrd";
|
||||
private int[][] keyArray = new int[][]{{1, 4, 2}, {2, 4, 1}, {4, 1, 2}};
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/hill";
|
||||
private static final String decodedString = "Message to^encoded";
|
||||
private static final String encodedString = "Mgkeqge ul^ikhisplrd";
|
||||
private static final int[][] keyArray = new int[][]{{1, 4, 2}, {2, 4, 1}, {4, 1, 2}};
|
||||
private static final String hillName = "hillName";
|
||||
private static final String hillDescription = "hillDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -55,26 +60,29 @@ public class HillCipherControllerIntegrationTest extends CipherStreamControllerI
|
||||
encodedNode.set(CipherParameterUtil.HILL_KEY, mapper.valueToTree(keyArray));
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString + "xx");
|
||||
|
||||
ReflectionTestUtils.setField(hillCipherController, "hillName", hillName);
|
||||
ReflectionTestUtils.setField(hillCipherController, "hillDescription", hillDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.HILL_CIPHER_NAME, CipherInfoUtil.HILL_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(hillName, hillDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.HILL_CIPHER_NAME))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.HILL_CIPHER_DESCRIPTION));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(hillName))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(hillDescription));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(hillLogger, times(1)).info("Getting info for {}", CipherInfoUtil.HILL_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.HILL_CIPHER_NAME);
|
||||
verify(hillLogger, times(1)).info("Getting info for {}", hillName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, hillName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -93,8 +101,8 @@ public class HillCipherControllerIntegrationTest extends CipherStreamControllerI
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(hillLogger, times(1)).info("Encoding {}", CipherInfoUtil.HILL_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.HILL_CIPHER_NAME);
|
||||
verify(hillLogger, times(1)).info("Encoding {}", hillName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, hillName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -113,8 +121,8 @@ public class HillCipherControllerIntegrationTest extends CipherStreamControllerI
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(hillLogger, times(1)).info("Encoding {}", CipherInfoUtil.HILL_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.HILL_CIPHER_NAME);
|
||||
verify(hillLogger, times(1)).info("Encoding {}", hillName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, hillName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -133,8 +141,8 @@ public class HillCipherControllerIntegrationTest extends CipherStreamControllerI
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(hillLogger, times(1)).info("Decoding {}", CipherInfoUtil.HILL_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.HILL_CIPHER_NAME);
|
||||
verify(hillLogger, times(1)).info("Decoding {}", hillName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, hillName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -153,8 +161,8 @@ public class HillCipherControllerIntegrationTest extends CipherStreamControllerI
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(hillLogger, times(1)).info("Decoding {}", CipherInfoUtil.HILL_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.HILL_CIPHER_NAME);
|
||||
verify(hillLogger, times(1)).info("Decoding {}", hillName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, hillName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.polysubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -25,15 +27,24 @@ public class HillCipherControllerTest{
|
||||
private HillCipherController hillCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String HILL_INPUT_STRING = "Message to^encode";
|
||||
private static final String HILL_OUTPUT_STRING = "Mgkeqge ul^ikhisp";
|
||||
private static final int[][] KEY = {{1, 4, 2}, {2, 4, 1}, {4, 1, 2}};
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String hillName = "hillName";
|
||||
private static final String hillDescription = "hillDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(hillCipherController, "hillName", hillName);
|
||||
ReflectionTestUtils.setField(hillCipherController, "hillDescription", hillDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.HILL_CIPHER_NAME, CipherInfoUtil.HILL_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(hillName, hillDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = hillCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,14 +28,18 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class MorseCodeControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private MorseCodeController morseCodeController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.polysubstitution.MorseCodeController")
|
||||
protected Logger morseLogger;
|
||||
//Fields
|
||||
private String url = "/morse";
|
||||
private String decodedString = "Message to^encode123";
|
||||
private String encodedString = "-- . ... ... .- --. . - --- . -. -.-. --- -.. . .---- ..--- ...--";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/morse";
|
||||
private static final String decodedString = "Message to^encode123";
|
||||
private static final String encodedString = "-- . ... ... .- --. . - --- . -. -.-. --- -.. . .---- ..--- ...--";
|
||||
private static final String morseName = "morseName";
|
||||
private static final String morseDescription = "morseDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -46,25 +51,28 @@ public class MorseCodeControllerIntegrationTest extends CipherStreamControllerIn
|
||||
encodedNode = mapper.createObjectNode();
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString.toUpperCase().replaceAll("[^A-Z0-9]", ""));
|
||||
|
||||
ReflectionTestUtils.setField(morseCodeController, "morseName", morseName);
|
||||
ReflectionTestUtils.setField(morseCodeController, "morseDescription", morseDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.MORSE_CIPHER_NAME, CipherInfoUtil.MORSE_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(morseName, morseDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.MORSE_CIPHER_NAME))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.MORSE_CIPHER_DESCRIPTION));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(morseName))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(morseDescription));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(morseLogger, times(1)).info("Getting info for {}", CipherInfoUtil.MORSE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.MORSE_CIPHER_NAME);
|
||||
verify(morseLogger, times(1)).info("Getting info for {}", morseName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, morseName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -83,8 +91,8 @@ public class MorseCodeControllerIntegrationTest extends CipherStreamControllerIn
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(morseLogger, times(1)).info("Encoding {}", CipherInfoUtil.MORSE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.MORSE_CIPHER_NAME);
|
||||
verify(morseLogger, times(1)).info("Encoding {}", morseName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, morseName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -103,8 +111,8 @@ public class MorseCodeControllerIntegrationTest extends CipherStreamControllerIn
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(morseLogger, times(1)).info("Encoding {}", CipherInfoUtil.MORSE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.MORSE_CIPHER_NAME);
|
||||
verify(morseLogger, times(1)).info("Encoding {}", morseName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, morseName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -123,8 +131,8 @@ public class MorseCodeControllerIntegrationTest extends CipherStreamControllerIn
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(morseLogger, times(1)).info("Decoding {}", CipherInfoUtil.MORSE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.MORSE_CIPHER_NAME);
|
||||
verify(morseLogger, times(1)).info("Decoding {}", morseName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, morseName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -143,8 +151,8 @@ public class MorseCodeControllerIntegrationTest extends CipherStreamControllerIn
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(morseLogger, times(1)).info("Decoding {}", CipherInfoUtil.MORSE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.MORSE_CIPHER_NAME);
|
||||
verify(morseLogger, times(1)).info("Decoding {}", morseName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, morseName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.polysubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,14 +25,23 @@ public class MorseCodeControllerTest{
|
||||
private MorseCodeController morseCodeController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String MORSE_INPUT_STRING = "SOS";
|
||||
private static final String MORSE_OUTPUT_STRING = "... --- ...";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String morseName = "morseName";
|
||||
private static final String morseDescription = "morseDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(morseCodeController, "morseName", morseName);
|
||||
ReflectionTestUtils.setField(morseCodeController, "morseDescription", morseDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.MORSE_CIPHER_NAME, CipherInfoUtil.MORSE_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(morseName, morseDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = morseCodeController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,16 +28,20 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class PlayfairCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private PlayfairCipherController playfairCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.polysubstitution.PlayfairCipherController")
|
||||
protected Logger playfairLogger;
|
||||
//Fields
|
||||
private String url = "/playfair";
|
||||
private String decodedString = "Hide the gold in - the@tree+stump";
|
||||
private String decodedStringPadded = "Hide the gold in - the@trexe+stump";
|
||||
private String encodedString = "Bmod zbx dnab ek - udm@uixmm+ouvif";
|
||||
private String keyword = "Play-fair@Exam ple";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/playfair";
|
||||
private static final String decodedString = "Hide the gold in - the@tree+stump";
|
||||
private static final String decodedStringPadded = "Hide the gold in - the@trexe+stump";
|
||||
private static final String encodedString = "Bmod zbx dnab ek - udm@uixmm+ouvif";
|
||||
private static final String keyword = "Play-fair@Exam ple";
|
||||
private static final String playfairName = "playfairName";
|
||||
private static final String playfairDescription = "playfairDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -56,26 +61,29 @@ public class PlayfairCipherControllerIntegrationTest extends CipherStreamControl
|
||||
encodedNode.put(CipherParameterUtil.KEYWORD, keyword);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedStringPadded);
|
||||
|
||||
ReflectionTestUtils.setField(playfairCipherController, "playfairName", playfairName);
|
||||
ReflectionTestUtils.setField(playfairCipherController, "playfairDescription", playfairDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.PLAYFAIR_CIPHER_NAME, CipherInfoUtil.PLAYFAIR_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(playfairName, playfairDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.PLAYFAIR_CIPHER_NAME))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.PLAYFAIR_CIPHER_DESCRIPTION));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(playfairName))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(playfairDescription));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(playfairLogger, times(1)).info("Getting info for {}", CipherInfoUtil.PLAYFAIR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.PLAYFAIR_CIPHER_NAME);
|
||||
verify(playfairLogger, times(1)).info("Getting info for {}", playfairName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, playfairName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -94,8 +102,8 @@ public class PlayfairCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(playfairLogger, times(1)).info("Encoding {}", CipherInfoUtil.PLAYFAIR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.PLAYFAIR_CIPHER_NAME);
|
||||
verify(playfairLogger, times(1)).info("Encoding {}", playfairName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, playfairName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -114,8 +122,8 @@ public class PlayfairCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(playfairLogger, times(1)).info("Encoding {}", CipherInfoUtil.PLAYFAIR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.PLAYFAIR_CIPHER_NAME);
|
||||
verify(playfairLogger, times(1)).info("Encoding {}", playfairName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, playfairName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -134,8 +142,8 @@ public class PlayfairCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(playfairLogger, times(1)).info("Decoding {}", CipherInfoUtil.PLAYFAIR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.PLAYFAIR_CIPHER_NAME);
|
||||
verify(playfairLogger, times(1)).info("Decoding {}", playfairName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, playfairName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -154,8 +162,8 @@ public class PlayfairCipherControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(playfairLogger, times(1)).info("Decoding {}", CipherInfoUtil.PLAYFAIR_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.PLAYFAIR_CIPHER_NAME);
|
||||
verify(playfairLogger, times(1)).info("Decoding {}", playfairName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, playfairName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.polysubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,16 +25,25 @@ public class PlayfairCipherControllerTest{
|
||||
private PlayfairCipherController playfairCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String PLAYFAIR_INPUT_STRING = "Hide the gold in - the@tree+stump";
|
||||
private static final String DECODED_INPUT_STRING = "Hide the gold in - the@trexe+stump";
|
||||
private static final String PLAYFAIR_OUTPUT_STRING = "Bmod zbx dnab ek - udm@uixmm+ouvif";
|
||||
private static final String PLAYFAIR_KEYWORD = "Play-fair@Exam ple";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String playfairName = "playfairName";
|
||||
private static final String playfairDescription = "playfairDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(playfairCipherController, "playfairName", playfairName);
|
||||
ReflectionTestUtils.setField(playfairCipherController, "playfairDescription", playfairDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.PLAYFAIR_CIPHER_NAME, CipherInfoUtil.PLAYFAIR_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(playfairName, playfairDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = playfairCipherController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class PolybiusSquareControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private PolybiusSquareController polybiusSquareController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.polysubstitution.PolybiusSquareController")
|
||||
protected Logger polybiusLogger;
|
||||
//Fields
|
||||
private String url = "/polybius";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "41124545233212 5115^124225152212";
|
||||
private String keyword = "keyword";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/polybius";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "41124545233212 5115^124225152212";
|
||||
private static final String keyword = "keyword";
|
||||
private static final String polybiusName = "polybiusName";
|
||||
private static final String polybiusDescription = "polybiusDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -55,26 +60,29 @@ public class PolybiusSquareControllerIntegrationTest extends CipherStreamControl
|
||||
encodedNode.put(CipherParameterUtil.KEYWORD, keyword);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString.toUpperCase());
|
||||
|
||||
ReflectionTestUtils.setField(polybiusSquareController, "polybiusName", polybiusName);
|
||||
ReflectionTestUtils.setField(polybiusSquareController, "polybiusDescription", polybiusDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME, CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(polybiusName, polybiusDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_DESCRIPTION));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(polybiusName))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(polybiusDescription));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(polybiusLogger, times(1)).info("Getting info for {}", CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME);
|
||||
verify(polybiusLogger, times(1)).info("Getting info for {}", polybiusName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, polybiusName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -93,8 +101,8 @@ public class PolybiusSquareControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(polybiusLogger, times(1)).info("Encoding {}", CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME);
|
||||
verify(polybiusLogger, times(1)).info("Encoding {}", polybiusName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, polybiusName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -113,8 +121,8 @@ public class PolybiusSquareControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(polybiusLogger, times(1)).info("Encoding {}", CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME);
|
||||
verify(polybiusLogger, times(1)).info("Encoding {}", polybiusName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, polybiusName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -133,8 +141,8 @@ public class PolybiusSquareControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(polybiusLogger, times(1)).info("Decoding {}", CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME);
|
||||
verify(polybiusLogger, times(1)).info("Decoding {}", polybiusName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, polybiusName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -153,8 +161,8 @@ public class PolybiusSquareControllerIntegrationTest extends CipherStreamControl
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(polybiusLogger, times(1)).info("Decoding {}", CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME);
|
||||
verify(polybiusLogger, times(1)).info("Decoding {}", polybiusName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, polybiusName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.polysubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,15 +25,23 @@ public class PolybiusSquareControllerTest{
|
||||
private PolybiusSquareController polybiusSquareController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String POLYBIUS_INPUT_STRING = "B A-T";
|
||||
private static final String POLYBIUS_OUTPUT_STRING = "15 14-52";
|
||||
private static final String POLYBIUS_KEYWORD = "Z Y+ X-";
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String polybiusName = "polybiusName";
|
||||
private static final String polybiusDescription = "polybiusDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(polybiusSquareController, "polybiusName", polybiusName);
|
||||
ReflectionTestUtils.setField(polybiusSquareController, "polybiusDescription", polybiusDescription);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_NAME, CipherInfoUtil.POLYBIUS_SQUARE_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(polybiusName, polybiusDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = polybiusSquareController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,15 +28,19 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class RailFenceControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private RailFenceController railFenceController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.polysubstitution.RailFenceController")
|
||||
protected Logger railFenceLogger;
|
||||
//Fields
|
||||
private String url = "/railFence";
|
||||
private String decodedString = "Message to^encode";
|
||||
private String encodedString = "Maooesg te^cdsene";
|
||||
private int rails = 3;
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/railFence";
|
||||
private static final String decodedString = "Message to^encode";
|
||||
private static final String encodedString = "Maooesg te^cdsene";
|
||||
private static final int rails = 3;
|
||||
private static final String railFenceName = "railFenceName";
|
||||
private static final String railFenceDescription = "railFenceDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -55,26 +60,29 @@ public class RailFenceControllerIntegrationTest extends CipherStreamControllerIn
|
||||
encodedNode.put(CipherParameterUtil.RAIL_FENCE_RAILS, rails);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(railFenceController, "railFenceName", railFenceName);
|
||||
ReflectionTestUtils.setField(railFenceController, "railFenceDescription", railFenceDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.RAIL_FENCE_CIPHER_NAME, CipherInfoUtil.RAIL_FENCE_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(railFenceName, railFenceDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.RAIL_FENCE_CIPHER_NAME))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.RAIL_FENCE_CIPHER_DESCRIPTION));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(railFenceName))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(railFenceDescription));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(railFenceLogger, times(1)).info("Getting info for {}", CipherInfoUtil.RAIL_FENCE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.RAIL_FENCE_CIPHER_NAME);
|
||||
verify(railFenceLogger, times(1)).info("Getting info for {}", railFenceName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, railFenceName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -93,8 +101,8 @@ public class RailFenceControllerIntegrationTest extends CipherStreamControllerIn
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(railFenceLogger, times(1)).info("Encoding {}", CipherInfoUtil.RAIL_FENCE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.RAIL_FENCE_CIPHER_NAME);
|
||||
verify(railFenceLogger, times(1)).info("Encoding {}", railFenceName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, railFenceName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -113,8 +121,8 @@ public class RailFenceControllerIntegrationTest extends CipherStreamControllerIn
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(railFenceLogger, times(1)).info("Encoding {}", CipherInfoUtil.RAIL_FENCE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.RAIL_FENCE_CIPHER_NAME);
|
||||
verify(railFenceLogger, times(1)).info("Encoding {}", railFenceName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, railFenceName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -133,8 +141,8 @@ public class RailFenceControllerIntegrationTest extends CipherStreamControllerIn
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(railFenceLogger, times(1)).info("Decoding {}", CipherInfoUtil.RAIL_FENCE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.RAIL_FENCE_CIPHER_NAME);
|
||||
verify(railFenceLogger, times(1)).info("Decoding {}", railFenceName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, railFenceName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -153,8 +161,8 @@ public class RailFenceControllerIntegrationTest extends CipherStreamControllerIn
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(railFenceLogger, times(1)).info("Decoding {}", CipherInfoUtil.RAIL_FENCE_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.RAIL_FENCE_CIPHER_NAME);
|
||||
verify(railFenceLogger, times(1)).info("Decoding {}", railFenceName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, railFenceName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.polysubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,15 +25,24 @@ public class RailFenceControllerTest{
|
||||
private RailFenceController railFenceController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String RAIL_FENCE_INPUT_STRING = "Message to^encode";
|
||||
private static final String RAIL_FENCE_OUTPUT_STRING = "Moetese ne^sgcdao";
|
||||
private static final int RAIL_FENCE_RAILS = 5;
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String railFenceName = "railFenceName";
|
||||
private static final String railFenceDescription = "railFenceDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(railFenceController, "railFenceName", railFenceName);
|
||||
ReflectionTestUtils.setField(railFenceController, "railFenceDescription", railFenceDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.RAIL_FENCE_CIPHER_NAME, CipherInfoUtil.RAIL_FENCE_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(railFenceName, railFenceDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = railFenceController.getCipherInfo();
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -27,17 +28,21 @@ import com.mattrixwv.cipherstream.utils.CipherParameterUtil;
|
||||
public class TrifidCipherControllerIntegrationTest extends CipherStreamControllerIntegrationTestBase{
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired
|
||||
private TrifidCipherController trifidCipherController;
|
||||
//Loggers
|
||||
@Mock(name = "com.mattrixwv.cipherstream.controller.polysubstitution.TrifidCipherController")
|
||||
protected Logger trifidLogger;
|
||||
//Fields
|
||||
private String url = "/trifid";
|
||||
private String decodedString = "Message to^encode+";
|
||||
private String encodedString = "Gqdokpd od^ljvflf+";
|
||||
private String keyword = "keyword";
|
||||
private String trifidFill = "=";
|
||||
private int grouplength = Integer.MAX_VALUE;
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String url = "/trifid";
|
||||
private static final String decodedString = "Message to^encode+";
|
||||
private static final String encodedString = "Gqdokpd od^ljvflf+";
|
||||
private static final String keyword = "keyword";
|
||||
private static final String trifidFill = "=";
|
||||
private static final int grouplength = Integer.MAX_VALUE;
|
||||
private static final String trifidName = "trifidName";
|
||||
private static final String trifidDescription = "trifidDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
@@ -61,26 +66,29 @@ public class TrifidCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
encodedNode.put(CipherParameterUtil.TRIFID_GROUP_LENGTH, grouplength);
|
||||
encodedNode.put(CipherParameterUtil.INPUT_STRING, encodedString);
|
||||
encodedNode.put(CipherParameterUtil.OUTPUT_STRING, decodedString);
|
||||
|
||||
ReflectionTestUtils.setField(trifidCipherController, "trifidName", trifidName);
|
||||
ReflectionTestUtils.setField(trifidCipherController, "trifidDescription", trifidDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCipherInfo() throws Exception{
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.TRIFID_CIPHER_NAME, CipherInfoUtil.TRIFID_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(trifidName, trifidDescription);
|
||||
|
||||
mockMvc.perform(get(url)
|
||||
.header("X-Request-Id", requestId)
|
||||
.header("X-Forwarded-For", ipAddress))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(CipherInfoUtil.TRIFID_CIPHER_NAME))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(CipherInfoUtil.TRIFID_CIPHER_DESCRIPTION));
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_NAME).value(trifidName))
|
||||
.andExpect(jsonPath(CipherInfoUtil.CIPHER_DESCRIPTION).value(trifidDescription));
|
||||
|
||||
//Filter
|
||||
super.verifyFilter(url);
|
||||
//Controller
|
||||
verify(trifidLogger, times(1)).info("Getting info for {}", CipherInfoUtil.TRIFID_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.TRIFID_CIPHER_NAME);
|
||||
verify(trifidLogger, times(1)).info("Getting info for {}", trifidName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, trifidName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", infoNode);
|
||||
}
|
||||
@@ -99,8 +107,8 @@ public class TrifidCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(trifidLogger, times(1)).info("Encoding {}", CipherInfoUtil.TRIFID_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.TRIFID_CIPHER_NAME);
|
||||
verify(trifidLogger, times(1)).info("Encoding {}", trifidName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, trifidName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", decodedNode);
|
||||
}
|
||||
@@ -119,8 +127,8 @@ public class TrifidCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/encode");
|
||||
//Controller
|
||||
verify(trifidLogger, times(1)).info("Encoding {}", CipherInfoUtil.TRIFID_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.TRIFID_CIPHER_NAME);
|
||||
verify(trifidLogger, times(1)).info("Encoding {}", trifidName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, trifidName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
@@ -139,8 +147,8 @@ public class TrifidCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(trifidLogger, times(1)).info("Decoding {}", CipherInfoUtil.TRIFID_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.TRIFID_CIPHER_NAME);
|
||||
verify(trifidLogger, times(1)).info("Decoding {}", trifidName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, trifidName);
|
||||
//Cipher Aspect
|
||||
verify(aspectLogger, times(1)).info("CipherStream log {}", encodedNode);
|
||||
}
|
||||
@@ -159,8 +167,8 @@ public class TrifidCipherControllerIntegrationTest extends CipherStreamControlle
|
||||
//Filter
|
||||
super.verifyFilter(url + "/decode");
|
||||
//Controller
|
||||
verify(trifidLogger, times(1)).info("Decoding {}", CipherInfoUtil.TRIFID_CIPHER_NAME);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, CipherInfoUtil.TRIFID_CIPHER_NAME);
|
||||
verify(trifidLogger, times(1)).info("Decoding {}", trifidName);
|
||||
verify(mdc, times(1)).put(CipherStreamLoggingAspect.CIPHER_NAME_LOGGING, trifidName);
|
||||
//Cipher Aspect
|
||||
verifyNoInteractions(aspectLogger);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package com.mattrixwv.cipherstream.controller.polysubstitution;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -23,17 +25,26 @@ public class TrifidCipherControllerTest{
|
||||
private TrifidCipherController trifidCipherController;
|
||||
//Fields
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String TRIFID_INPUT_STRING = "Message to^encode";
|
||||
private static final String TRIFID_OUTPUT_STRING = "Gpjqdvd of^odlklf";
|
||||
private static final String TRIFID_KEYWORD = CipherParameterUtil.KEYWORD;
|
||||
private static final char TRIFID_FILL_ID = '+';
|
||||
private static final int TRIFID_GROUP_LENGTH = 3;
|
||||
private static final ObjectNode blankNode = mapper.createObjectNode();
|
||||
private static final String trifidName = "trifidName";
|
||||
private static final String trifidDescription = "trifidDescription";
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup(){
|
||||
ReflectionTestUtils.setField(trifidCipherController, "trifidName", trifidName);
|
||||
ReflectionTestUtils.setField(trifidCipherController, "trifidDescription", trifidDescription);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void tetGetCipherInfo(){
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(CipherInfoUtil.TRIFID_CIPHER_NAME, CipherInfoUtil.TRIFID_CIPHER_DESCRIPTION);
|
||||
ObjectNode infoNode = CipherInfoUtil.buildInfoNode(trifidName, trifidDescription);
|
||||
|
||||
|
||||
ObjectNode returnedJson = trifidCipherController.getCipherInfo();
|
||||
|
||||
Reference in New Issue
Block a user