diff options
author | 2018-08-13 11:56:17 +0200 | |
---|---|---|
committer | 2018-08-13 12:41:49 +0200 | |
commit | 5003049edb722ad7c415981fa2c85c17ba876264 (patch) | |
tree | 72ebacd114589c238ce0537195a3a472500f43d3 /vpp-classifier/impl/src/test | |
parent | 0a9c0f91cccc371c802a47ac25443f3c7837f939 (diff) |
Check length of classify session's match vector (HC2VPP-373)
Change-Id: I45028349f81a756d03d46e02af40041a7cae1fec
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vpp-classifier/impl/src/test')
-rw-r--r-- | vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java b/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java index ccb02708e..68d20a728 100644 --- a/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java +++ b/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java @@ -99,6 +99,8 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest { when(classfierContext.getTableIndex(TABLE_NAME, mappingContext)).thenReturn(TABLE_INDEX); final ClassifyTable table = mock(ClassifyTable.class); + when(table.getMask()).thenReturn(new HexString("00:00:00:00:00:00:ff:FF:ff:ff:ff:FF:00:00:00:00")); + when(table.getSkipNVectors()).thenReturn(0L); when(table.getClassifierNode()).thenReturn(new VppNodeName("ip4-classifier")); when(writeContext.readAfter(ArgumentMatchers.any())).thenReturn(Optional.of(table)); when(writeContext.readBefore(ArgumentMatchers.any())).thenReturn(Optional.of(table)); @@ -190,4 +192,32 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest { final InstanceIdentifier<ClassifySession> id = getClassifySessionId(TABLE_NAME, match); customizer.writeCurrentAttributes(id, classifySession, writeContext); } + + @Test(expected = IllegalArgumentException.class) + public void testCreateInvalidMatchLength() throws WriteFailedException { + final ClassifyTable table = mock(ClassifyTable.class); + when(table.getMask()).thenReturn(new HexString("00:00:00:00:00:00:ff:FF:ff:ff:ff:FF:00:00:00:00")); + when(table.getSkipNVectors()).thenReturn(1L); + when(writeContext.readAfter(ArgumentMatchers.any())).thenReturn(Optional.of(table)); + + final String match = "00:00:00:00:00:00:01:02:03:04:05:06:00:00:00:00"; + final ClassifySession classifySession = generateClassifySession(SESSION_INDEX, match); + final InstanceIdentifier<ClassifySession> id = getClassifySessionId(TABLE_NAME, match); + customizer.writeCurrentAttributes(id, classifySession, writeContext); + } + + @Test + public void testCreateSkipOneVector() throws WriteFailedException { + final ClassifyTable table = mock(ClassifyTable.class); + when(table.getMask()).thenReturn(new HexString("00:00:00:00:00:00:ff:FF:ff:ff:ff:FF:00:00:00:00")); + when(table.getSkipNVectors()).thenReturn(1L); + when(writeContext.readAfter(ArgumentMatchers.any())).thenReturn(Optional.of(table)); + whenClassifyAddDelSessionThenSuccess(); + + final String match = + "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:01:02:03:04:05:06:00:00:00:00"; + final ClassifySession classifySession = generateClassifySession(SESSION_INDEX, match); + final InstanceIdentifier<ClassifySession> id = getClassifySessionId(TABLE_NAME, match); + customizer.writeCurrentAttributes(id, classifySession, writeContext); + } }
\ No newline at end of file |