Skip to content

Commit

Permalink
feat: add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
aloisio-m-bastian committed Feb 27, 2025
1 parent e9c033a commit aedb0c4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
const fixtures = {
wafRulesMock: {
hit_count: 10,
top_10_ips: [{ ip: '120.103.10' }],
top_10_ips: [{ ip: '120.103.10', hits: 10 }],
rule_id: 1000,
ip_count: 8,
match_zone: 'value',
path_count: 10,
top_10_countries: [{ country: 'Brazil' }],
top_10_countries: [{ country: 'Brazil', hits: 10 }],
matches_on: 'query_string',
country_count: 10,
match_value: 'value',
top_10_paths: [{ path: '/get' }]
top_10_paths: [{ path: '/get', hits: 10 }]
}
}

Expand Down Expand Up @@ -63,17 +63,17 @@ describe('WafRulesService', () => {
expect(result).toEqual([
{
hitCount: fixtures.wafRulesMock.hit_count,
topIps: ['120.103.10'],
topIps: ['120.103.10 (10 hits)'],
id: 0,
ruleId: fixtures.wafRulesMock.rule_id,
ipCount: fixtures.wafRulesMock.ip_count,
matchZone: fixtures.wafRulesMock.match_zone,
pathCount: fixtures.wafRulesMock.path_count,
topCountries: ['Brazil'],
topCountries: ['Brazil (10 hits)'],
matchesOn: fixtures.wafRulesMock.matches_on,
ruleDescription: fixtures.wafRulesMock.rule_description,
countryCount: fixtures.wafRulesMock.country_count,
topPaths: ['/get'],
topPaths: ['/get (10 hits)'],
matchValue: fixtures.wafRulesMock.match_value
}
])
Expand Down
17 changes: 13 additions & 4 deletions src/views/WafRules/Drawer/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import GoBack from '@/templates/action-bar-block/go-back'
import InputText from 'primevue/inputtext'
import EmptyDrawer from '@/templates/empty-drawer'
import { columnBuilder } from '@/templates/list-table-block/columns/column-builder'
import WithSelectionBehavior from '@/templates/list-table-block/with-selection-behavior.vue'
defineOptions({
Expand Down Expand Up @@ -74,7 +75,6 @@
loading.value = true
const response = await props.listService(namePath)
possibleAttacks.value = response
console.log(possibleAttacks.value)
} catch (error) {
showToast('error', error)
} finally {
Expand Down Expand Up @@ -133,17 +133,26 @@
{
field: 'topIps',
header: 'Top 10 IPs',
sortable: true
sortable: true,
type: 'component',
component: (columnData) =>
columnBuilder({ data: columnData, columnAppearance: 'expand-column' })
},
{
field: 'topCountries',
header: 'Top 10 Countries',
sortable: true
sortable: true,
type: 'component',
component: (columnData) =>
columnBuilder({ data: columnData, columnAppearance: 'expand-column' })
},
{
field: 'topPaths',
header: 'Top 10 Paths',
sortable: true
sortable: true,
type: 'component',
component: (columnData) =>
columnBuilder({ data: columnData, columnAppearance: 'expand-column' })
}
]
</script>
Expand Down

0 comments on commit aedb0c4

Please sign in to comment.