Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tests): Add more Unit tests #5364

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

Zaid-maker
Copy link
Contributor

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

Add more Tests tests might get failed

Type of change

Please delete any options that are not relevant.

  • Other

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas (including JSDoc for methods)
  • My changes generates no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.

test/backend-test/test-notification.js Fixed Show fixed Hide fixed
test/backend-test/test-notification.js Fixed Show fixed Hide fixed
test/backend-test/test-notification.js Fixed Show fixed Hide fixed
test/backend-test/test-notification.js Fixed Show fixed Hide fixed
test/backend-test/test-notification.js Fixed Show fixed Hide fixed

const formatted = notification.format(msg);
assert.ok(formatted.includes("Test Monitor"), "Should include monitor name");
assert.ok(formatted.includes("https://test.mydomain.com"), "Should include full URL");

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High test

'
https://test.mydomain.com
' can be anywhere in the URL, and arbitrary hosts may come before or after it.
};

const maliciousFormatted = notification.format(maliciousMsg);
assert.ok(!maliciousFormatted.includes("test.mydomain.com"), "Should not include test.mydomain.com as substring");

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High test

'
test.mydomain.com
' can be anywhere in the URL, and arbitrary hosts may come before or after it.

const maliciousFormatted = notification.format(maliciousMsg);
assert.ok(!maliciousFormatted.includes("test.mydomain.com"), "Should not include test.mydomain.com as substring");
assert.ok(maliciousFormatted.includes("https://malicious.mydomain.com"), "Should include exact malicious URL");

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High test

'
https://malicious.mydomain.com
' can be anywhere in the URL, and arbitrary hosts may come before or after it.
};
const upFormatted = notification.format(upMsg);
assert.ok(upFormatted.includes("up"), "Should indicate UP status");
assert.ok(upFormatted.includes("https://test1.mydomain.com"), "Should include complete URL");

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High test

'
https://test1.mydomain.com
' can be anywhere in the URL, and arbitrary hosts may come before or after it.
};
const downFormatted = notification.format(downMsg);
assert.ok(downFormatted.includes("down"), "Should indicate DOWN status");
assert.ok(downFormatted.includes("https://test2.mydomain.com"), "Should include complete URL");

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High test

'
https://test2.mydomain.com
' can be anywhere in the URL, and arbitrary hosts may come before or after it.
@Zaid-maker
Copy link
Contributor Author

I don't know why the backend-test failing I found no error in it still fails. Needs to look into it.

@louislam
Copy link
Owner

I don't know why the backend-test failing I found no error in it still fails. Needs to look into it.

When checking the url, I think you should parse into a URL by using new URL(...) for security.

@Zaid-maker
Copy link
Contributor Author

When checking the url, I think you should parse into a URL by using new URL(...) for security.

Ohh that could work i will look into into it!

Zaid-maker and others added 7 commits November 27, 2024 12:06
- All DNS record types
- Various DNS providers
- Edge cases and error conditions
- Response format validation
- Performance metrics
- Security validations
- Better test organization
- More comprehensive coverage
- Improved error handling
- Better async cleanup
- More realistic test scenarios
}

// Check for potential URL substring issues
if (testCase.url.includes("test.mydomain.com")) {

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High test

'
test.mydomain.com
' can be anywhere in the URL, and arbitrary hosts may come before or after it.
@Zaid-maker
Copy link
Contributor Author

Will pick up this PR soon and complete it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants