Skip to content

Commit

Permalink
feat: Empty rows in the expressions configuration don't result in any…
Browse files Browse the repository at this point in the history
…-regexps
  • Loading branch information
dploeger committed May 9, 2022
1 parent d376474 commit ec6715b
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/api/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ export class Configuration {

// Load exceptions

this.exceptions = this._getConfigurationFromPanel($, 'Exceptions').map<RegExp>((value) => new RegExp(value.regularexpression))
this.exceptions = this._getConfigurationFromPanel($, 'Exceptions')
.filter((value) => value.regularexpression !== '')
.map<RegExp>((value) => new RegExp(value.regularexpression))

this.notificationSubjectTemplate = $(
'ac\\:parameter:contains("Notification Template") + ac\\:rich-text-body ac\\:parameter:contains("Subject") + ac\\:rich-text-body'
Expand Down
9 changes: 9 additions & 0 deletions test/ConfigurationTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,13 @@ describe('The Configuration API', (): void => {

chai.expect(configuration.notificationFrom).to.eq('Notification <[email protected]>')
})
it('supports empty exclusion lines', async (): Promise<void> => {
const mockServer = new MockServer('https://example.com')
mockServer.addConfigurationDocumentEndpoint()

const configuration = new Configuration('https://example.com', 'nobody', 'nothing', '12346')
await configuration.load()

chai.expect(configuration.exceptions).to.have.lengthOf(0)
})
})
137 changes: 137 additions & 0 deletions test/MockServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,143 @@ export class MockServer {
</table>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='93f1d981-c841-4cb4-b6e2-5940dfe69132'>
<ac:parameter ac:name='title'>Notification Template</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='f8503e48-c671-4ed6-897c-def2b2c3fa29'>
<ac:parameter ac:name='title'>Subject</ac:parameter>
<ac:rich-text-body><p>${MockServer.NOTIFICATION_SUBJECT}</p></ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='63c16112-dea3-434e-b1cb-467ff4e36d5f'>
<ac:parameter ac:name='title'>Body</ac:parameter>
<ac:rich-text-body>${MockServer.NOTIFICATION_BODY}</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
`,
},
},
})
this._scope
.get('/rest/api/content/12346?expand=body.storage')
.basicAuth({
user: 'nobody',
pass: 'nothing',
})
.reply(200, {
body: {
storage: {
value: `
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='4671afbe-d914-470a-bb9e-8b7321f60f79'>
<ac:parameter ac:name='title'>Configuration</ac:parameter>
<ac:rich-text-body>
<table class='wrapped'>
<colgroup>
<col/>
<col/>
</colgroup>
<tbody>
<tr>
<th>Space</th>
<td>SAMPLE</td>
</tr>
<tr>
<th>Domain</th>
<td>example.com</td>
</tr>
<tr>
<th>NotificationFrom</th>
<td>Notification &lt;[email protected]&gt;</td>
</tr>
</tbody>
</table>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='ecfe796e-b701-4f30-a74a-b94dbb33daff'>
<ac:parameter ac:name='title'>SMTP</ac:parameter>
<ac:rich-text-body>
<table>
<colgroup>
<col/>
<col/>
</colgroup>
<tbody>
<tr>
<th>Host</th>
<td colspan='1'>localhost</td>
</tr>
<tr>
<th>Port</th>
<td colspan='1'>25</td>
</tr>
</tbody>
</table>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='f19cd8b2-57e0-4c68-a823-8a2daee08c12'>
<ac:parameter ac:name='title'>Checks</ac:parameter>
<ac:rich-text-body>
<table class='wrapped'>
<colgroup>
<col/>
<col/>
</colgroup>
<tbody>
<tr>
<th>Labels</th>
<th>MaxAge</th>
</tr>
<tr>
<td>test1</td>
<td>356</td>
</tr>
<tr>
<td colspan='1'>test2</td>
<td colspan='1'>1234</td>
</tr>
</tbody>
</table>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='1d192d60-7e69-4af8-8dd6-4006a7bfc952'>
<ac:parameter ac:name='title'>Maintainer</ac:parameter>
<ac:rich-text-body>
<table class='wrapped'>
<colgroup>
<col/>
<col/>
</colgroup>
<tbody>
<tr>
<th>Pagepattern</th>
<th>Maintainer</th>
</tr>
<tr>
<td>main/Test/.*</td>
<td>maintainer,_lastauthor</td>
</tr>
</tbody>
</table>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='1d192d60-7e69-4af8-8dd6-4006a7bfc952'>
<ac:parameter ac:name='title'>Exceptions</ac:parameter>
<ac:rich-text-body>
<table class='wrapped'>
<colgroup>
<col/>
</colgroup>
<tbody>
<tr>
<th>RegularExpression</th>
</tr>
<tr>
<td></td>
</tr>
</tbody>
</table>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:name='panel' ac:schema-version='1' ac:macro-id='93f1d981-c841-4cb4-b6e2-5940dfe69132'>
<ac:parameter ac:name='title'>Notification Template</ac:parameter>
<ac:rich-text-body>
Expand Down

0 comments on commit ec6715b

Please sign in to comment.