Merge branch 'louislam:master' into master

This commit is contained in:
Ioma Taani 2021-11-08 14:49:06 +01:00 committed by GitHub
commit 60019a4229
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 252 additions and 37 deletions

View file

@ -1,6 +1,6 @@
{
"name": "uptime-kuma",
"version": "1.10.0",
"version": "1.10.1",
"license": "MIT",
"repository": {
"type": "git",
@ -30,13 +30,13 @@
"build-docker": "npm run build-docker-debian && npm run build-docker-alpine",
"build-docker-alpine-base": "docker buildx build -f docker/alpine-base.dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:base-alpine . --push",
"build-docker-debian-base": "docker buildx build -f docker/debian-base.dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:base-debian . --push",
"build-docker-alpine": "docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:alpine -t louislam/uptime-kuma:1-alpine -t louislam/uptime-kuma:1.10.0-alpine --target release . --push",
"build-docker-debian": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 -t louislam/uptime-kuma:1.10.0 -t louislam/uptime-kuma:debian -t louislam/uptime-kuma:1-debian -t louislam/uptime-kuma:1.10.0-debian --target release . --push",
"build-docker-alpine": "docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:alpine -t louislam/uptime-kuma:1-alpine -t louislam/uptime-kuma:1.10.1-alpine --target release . --push",
"build-docker-debian": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma -t louislam/uptime-kuma:1 -t louislam/uptime-kuma:1.10.1 -t louislam/uptime-kuma:debian -t louislam/uptime-kuma:1-debian -t louislam/uptime-kuma:1.10.1-debian --target release . --push",
"build-docker-nightly": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly --target nightly . --push",
"build-docker-nightly-alpine": "docker buildx build -f docker/dockerfile-alpine --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:nightly-alpine --target nightly . --push",
"build-docker-nightly-amd64": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push --progress plain",
"upload-artifacts": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain",
"setup": "git checkout 1.10.0 && npm ci --production && npm run download-dist",
"setup": "git checkout 1.10.1 && npm ci --production && npm run download-dist",
"download-dist": "node extra/download-dist.js",
"update-version": "node extra/update-version.js",
"mark-as-nightly": "node extra/mark-as-nightly.js",

View file

@ -141,6 +141,7 @@ class Monitor extends BeanModel {
// Do not do any queries/high loading things before the "bean.ping"
let startTime = dayjs().valueOf();
debug(`[${this.name}] Prepare Options for axios`);
const options = {
url: this.url,
method: (this.method || "get").toLowerCase(),
@ -160,6 +161,8 @@ class Monitor extends BeanModel {
return checkStatusCode(status, this.getAcceptedStatuscodes());
},
};
debug(`[${this.name}] Axios Request`);
let res = await axios.request(options);
bean.msg = `${res.status} - ${res.statusText}`;
bean.ping = dayjs().valueOf() - startTime;
@ -167,12 +170,13 @@ class Monitor extends BeanModel {
// Check certificate if https is used
let certInfoStartTime = dayjs().valueOf();
if (this.getUrl()?.protocol === "https:") {
debug(`[${this.name}] Check cert`);
try {
let tlsInfoObject = checkCertificate(res);
tlsInfo = await this.updateTlsInfo(tlsInfoObject);
if (!this.getIgnoreTls()) {
debug("call sendCertNotification");
debug(`[${this.name}] call sendCertNotification`);
await this.sendCertNotification(tlsInfoObject);
}
@ -351,15 +355,19 @@ class Monitor extends BeanModel {
let beatInterval = this.interval;
debug(`[${this.name}] Check isImportant`);
let isImportant = Monitor.isImportantBeat(isFirstBeat, previousBeat?.status, bean.status);
// Mark as important if status changed, ignore pending pings,
// Don't notify if disrupted changes to up
if (isImportant) {
bean.important = true;
debug(`[${this.name}] sendNotification`);
await Monitor.sendNotification(isFirstBeat, this, bean);
// Clear Status Page Cache
debug(`[${this.name}] apicache clear`);
apicache.clear();
} else {
@ -377,10 +385,14 @@ class Monitor extends BeanModel {
console.warn(`Monitor #${this.id} '${this.name}': Failing: ${bean.msg} | Interval: ${beatInterval} seconds | Type: ${this.type}`);
}
debug(`[${this.name}] Send to socket`);
io.to(this.user_id).emit("heartbeat", bean.toJSON());
Monitor.sendStats(io, this.id, this.user_id);
debug(`[${this.name}] Store`);
await R.store(bean);
debug(`[${this.name}] prometheus.update`);
prometheus.update(bean, tlsInfo);
previousBeat = bean;
@ -394,7 +406,10 @@ class Monitor extends BeanModel {
}
}
debug(`[${this.name}] SetTimeout for next check.`);
this.heartbeatInterval = setTimeout(safeBeat, beatInterval * 1000);
} else {
console.log(`[${this.name}] isStop = true, no next check.`);
}
};

View file

@ -101,6 +101,10 @@ router.get("/api/status-page/config", async (_request, response) => {
config.statusPagePublished = true;
}
if (! config.statusPageTags) {
config.statusPageTags = false;
}
if (! config.title) {
config.title = "Uptime Kuma";
}
@ -140,10 +144,25 @@ router.get("/api/status-page/monitor-list", cache("5 minutes"), async (_request,
try {
await checkPublished();
const publicGroupList = [];
let list = await R.find("group", " public = 1 ORDER BY weight ");
const tagsVisible = (await getSettings("statusPage")).statusPageTags;
const list = await R.find("group", " public = 1 ORDER BY weight ");
for (let groupBean of list) {
publicGroupList.push(await groupBean.toPublicJSON());
let monitorGroup = await groupBean.toPublicJSON();
if (tagsVisible) {
monitorGroup.monitorList = await Promise.all(monitorGroup.monitorList.map(async (monitor) => {
// Includes tags as an array in response, allows for tags to be displayed on public status page
const tags = await R.getAll(
`SELECT monitor_tag.monitor_id, monitor_tag.value, tag.name, tag.color
FROM monitor_tag
JOIN tag
ON monitor_tag.tag_id = tag.id
WHERE monitor_tag.monitor_id = ?`, [monitor.id]
);
return {...monitor, tags: tags}
}));
}
publicGroupList.push(monitorGroup);
}
response.json(publicGroupList);

View file

@ -201,8 +201,13 @@ const getDaysRemaining = (validFrom, validTo) => {
// param: info - the chain obtained from getPeerCertificate()
const parseCertificateInfo = function (info) {
let link = info;
let i = 0;
const existingList = {};
while (link) {
debug(`[${i}] ${link.fingerprint}`);
if (!link.valid_from || !link.valid_to) {
break;
}
@ -210,15 +215,24 @@ const parseCertificateInfo = function (info) {
link.validFor = link.subjectaltname?.replace(/DNS:|IP Address:/g, "").split(", ");
link.daysRemaining = getDaysRemaining(new Date(), link.validTo);
existingList[link.fingerprint] = true;
// Move up the chain until loop is encountered
if (link.issuerCertificate == null) {
break;
} else if (link.fingerprint == link.issuerCertificate.fingerprint) {
} else if (link.issuerCertificate.fingerprint in existingList) {
debug(`[Last] ${link.issuerCertificate.fingerprint}`);
link.issuerCertificate = null;
break;
} else {
link = link.issuerCertificate;
}
// Should be no use, but just in case.
if (i > 500) {
throw new Error("Dead loop occurred in parseCertificateInfo");
}
i++;
}
return info;
@ -228,6 +242,7 @@ exports.checkCertificate = function (res) {
const info = res.request.res.socket.getPeerCertificate(true);
const valid = res.request.res.socket.authorized || false;
debug("Parsing Certificate Info");
const parsedInfo = parseCertificateInfo(info);
return {

View file

@ -346,6 +346,10 @@ textarea.form-control {
&.active {
background-color: #cdf8f4;
}
.tags {
// Removes margin to line up tags list with uptime percentage
margin-left: -0.25rem;
}
}
}

View file

@ -41,6 +41,9 @@
<Uptime :monitor="monitor.element" type="24" :pill="true" />
{{ monitor.element.name }}
</div>
<div class="tags">
<Tag v-for="tag in monitor.element.tags" :key="tag" :item="tag" :size="'sm'" />
</div>
</div>
<div :key="$root.userHeartbeatBar" class="col-3 col-md-4">
<HeartbeatBar size="small" :monitor-id="monitor.element.id" />
@ -59,12 +62,14 @@
import Draggable from "vuedraggable";
import HeartbeatBar from "./HeartbeatBar.vue";
import Uptime from "./Uptime.vue";
import Tag from "./Tag.vue";
export default {
components: {
Draggable,
HeartbeatBar,
Uptime,
Tag,
},
props: {
editMode: {

View file

@ -1,5 +1,5 @@
<template>
<span :class="className">{{ uptime }}</span>
<span :class="className" :title="24 + $t('-hour')">{{ uptime }}</span>
</template>
<script>

View file

@ -2,15 +2,14 @@ export default {
languageName: "Hrvatski",
checkEverySecond: "Provjera svake {0} sekunde",
retryCheckEverySecond: "Ponovni pokušaj svake {0} sekunde",
retriesDescription: "Broj ponovnih pokušaja prije nego će se servis označiti kao DOWN te poslati obavijest",
retriesDescription: "Broj ponovnih pokušaja prije nego će se servis označiti kao nedostupan te poslati obavijest",
ignoreTLSError: "Ignoriraj TLS/SSL pogreške za HTTPS web stranice",
upsideDownModeDescription: "Preokreni logiku statusa. Ako je usluga dostupna, smatra se da je DOWN.",
upsideDownModeDescription: "Preokreni logiku statusa. Ako se primi pozitivan odgovor, smatra se da je usluga nedostupna.",
maxRedirectDescription: "Maksimalan broj preusmjeravanja. Postaviti na 0 kako bi se preusmjeravanja onemogućila.",
acceptedStatusCodesDescription: "Odaberite statusne kodove koji se smatraju uspješnim odgovorom.",
passwordNotMatchMsg: "Lozinke se ne poklapaju.",
notificationDescription: "Obavijesti će funkcionirati samo ako su dodijeljene monitoru.",
keywordDescription: "Ključna riječ za pretragu kao običan HTML ili u JSON formatu. Pretraga je case-sensitive.",
pauseDashboardHome: "Pauziraj",
keywordDescription: "Ključna riječ za pretragu, u obliku običnog HTML-a ili u JSON formatu. Pretraga je osjetljiva na velika i mala slova.",
deleteMonitorMsg: "Jeste li sigurni da želite izbrisati monitor?",
deleteNotificationMsg: "Jeste li sigurni da želite izbrisati ovu obavijest za sve monitore?",
resoverserverDescription: "Cloudflare je zadani DNS poslužitelj. Možete to promijeniti u bilo kojem trenutku.",
@ -25,7 +24,7 @@ export default {
twoFAVerifyLabel: "Unesite svoj 2FA token:",
tokenValidSettingsMsg: "Token je važeći! Sada možete spremiti postavke dvofaktorske autentikacije.",
confirmEnableTwoFAMsg: "Želite li omogućiti dvofaktorsku autentikaciju?",
confirmDisableTwoFAMsg: "Are you sure you want to disable dvofaktorsku autentikaciju?",
confirmDisableTwoFAMsg: "Jeste li sigurni da želite onemogućiti dvofaktorsku autentikaciju?",
Settings: "Postavke",
Dashboard: "Kontrolna ploča",
"New Update": "Novo ažuriranje",
@ -44,17 +43,18 @@ export default {
Down: "Nedostupno",
Pending: "U tijeku",
Unknown: "Nepoznato",
Pause: "Pauzirano",
Name: "Naziv monitora",
pauseDashboardHome: "Pauzirano",
Name: "Naziv",
Status: "Status",
DateTime: "Vremenska oznaka",
Message: "Izvještaj",
"No important events": "Nema važnih događaja",
Pause: "Pauziraj",
Resume: "Nastavi",
Edit: "Uredi",
Delete: "Obriši",
Current: "Trenutno",
Uptime: "Uptime",
Uptime: "Dostupnost",
"Cert Exp.": "Istek cert.",
days: "dana",
day: "dan",
@ -65,12 +65,12 @@ export default {
Ping: "Odziv",
"Monitor Type": "Vrsta Monitora",
Keyword: "Ključna riječ",
"Friendly Name": "Lijep naziv",
"Friendly Name": "Prilagođen naziv",
URL: "URL",
Hostname: "Domaćin",
Port: "Port",
"Heartbeat Interval": "Interval provjere",
Retries: "Ponovnih pokušaja",
Retries: "Broj ponovnih pokušaja",
"Heartbeat Retry Interval": "Interval ponovnih pokušaja",
Advanced: "Napredne postavke",
"Upside Down Mode": "Obrnuti način",
@ -86,14 +86,14 @@ export default {
Light: "Svijetli način",
Dark: "Tamni način",
Auto: "Automatski",
"Theme - Heartbeat Bar": "Tema - Statusna traka",
"Theme - Heartbeat Bar": "Tema za traku dostupnosti",
Normal: "Normalno",
Bottom: "Ispod",
None: "Isključeno",
Timezone: "Vremenska zona",
"Search Engine Visibility": "Vidljivost pretraživačima",
"Search Engine Visibility": "Vidljivost tražilicama",
"Allow indexing": "Dopusti indeksiranje",
"Discourage search engines from indexing site": "Sprječavanje indeksiranja stranice",
"Discourage search engines from indexing site": "Sprječavanje indeksiranja",
"Change Password": "Promjena lozinke",
"Current Password": "Trenutna lozinka",
"New Password": "Nova lozinka",
@ -103,7 +103,7 @@ export default {
"Enable Auth": "Omogući autentikaciju",
Logout: "Odjava",
Leave: "Poništi",
"I understand, please disable": "Razumijem, onemogući",
"I understand, please disable": "Razumijem, svejedno onemogući",
Confirm: "Potvrda",
Yes: "Da",
No: "Ne",
@ -112,10 +112,10 @@ export default {
"Remember me": "Zapamti me",
Login: "Prijava",
"No Monitors, please": "Nema monitora, ",
"add one": "dodaj jednog",
"add one": "dodaj jedan",
"Notification Type": "Tip obavijesti",
Email: "E-pošta",
Test: "Test",
Test: "Testiraj",
"Certificate Info": "Informacije o certifikatu",
"Resolver Server": "DNS poslužitelj",
"Resource Record Type": "Vrsta DNS zapisa",
@ -130,14 +130,14 @@ export default {
notAvailableShort: "N/A",
"Default enabled": "Omogući za nove monitore",
"Apply on all existing monitors": "Primijeni na postojeće monitore",
Create: "Create",
"Clear Data": "Clear Data",
Events: "Events",
Create: "Kreiraj",
"Clear Data": "Obriši podatke",
Events: "Događaji",
Heartbeats: "Provjere",
"Auto Get": "Automatski dohvat",
backupDescription: "Moguće je napraviti sigurnosnu kopiju svih monitora i obavijesti koja će biti spremljena kao JSON datoteka.",
backupDescription2: "Napomena: povijest i podaci o događajima nisu uključeni u sigurnosnu kopiju.",
backupDescription3: "Osjetljivi podaci poput tokena za obavijesti jesu uključeni u sigurnosnu kopiju. Zato je potrebno čuvati izvoz na sigurnom mjestu.",
backupDescription3: "Osjetljivi podaci poput tokena za obavijesti uključeni su u sigurnosnu kopiju. Zato je potrebno čuvati izvoz na sigurnom mjestu.",
alertNoFile: "Datoteka za uvoz nije odabrana.",
alertWrongFileType: "Datoteka za uvoz nije u JSON formatu.",
"Clear all statistics": "Obriši sve statistike",
@ -152,7 +152,7 @@ export default {
"2FA Settings": "Postavke 2FA",
"Two Factor Authentication": "Dvofaktorska autentikacija",
Active: "Aktivna",
Inactive: "Neaktivna",
Inactive: "Neaktivno",
Token: "Token",
"Show URI": "Pokaži URI",
Tags: "Oznake",
@ -172,7 +172,7 @@ export default {
"Search...": "Pretraga...",
"Avg. Ping": "Prosječni odziv",
"Avg. Response": "Prosječni odgovor",
"Entry Page": "Entry Page",
"Entry Page": "Početna stranica",
statusPageNothing: "Ovdje nema ničega, dodajte grupu ili monitor.",
"No Services": "Nema usluga",
"All Systems Operational": "Svi sustavi su operativni",
@ -183,7 +183,7 @@ export default {
"Edit Status Page": "Uredi Statusnu stranicu",
"Go to Dashboard": "Na Kontrolnu ploču",
"Status Page": "Statusna stranica",
defaultNotificationName: "Moja {notification} obavijest ({number})",
defaultNotificationName: "Moja {number}. {notification} obavijest",
here: "ovdje",
Required: "Potrebno",
telegram: "Telegram",
@ -195,11 +195,11 @@ export default {
"YOUR BOT TOKEN HERE": "OVDJE IDE TOKEN BOTA",
chatIDNotFound: "ID razgovora nije pronađen; prvo morate poslati poruku botu",
webhook: "Webhook",
"Post URL": "Post URL",
"Post URL": "URL Post zahtjeva",
"Content Type": "Tip sadržaja (Content Type)",
webhookJsonDesc: "{0} je dobra opcija za moderne HTTP poslužitelje poput Express.js-a",
webhookFormDataDesc: "{multipart} je moguća alternativa za PHP, samo je potrebno parsirati JSON koristeći {decodeFunction}",
smtp: "E-pošta (SMTP)",
smtp: "E-mail (SMTP)",
secureOptionNone: "Bez sigurnosti / STARTTLS (25, 587)",
secureOptionTLS: "TLS (465)",
"Ignore TLS Error": "Ignoriraj greške TLS-a",
@ -215,7 +215,7 @@ export default {
"Prefix Custom Message": "Prefiks prilagođene poruke",
"Hello @everyone is...": "Pozdrav {'@'}everyone...",
teams: "Microsoft Teams",
"Webhook URL": "URL Teams webhooka",
"Webhook URL": "URL webhooka",
wayToGetTeamsURL: "Više informacija o Teams webhookovima možete pročitati {0}.",
signal: "Signal",
Number: "Broj",
@ -242,7 +242,7 @@ export default {
promosms: "PromoSMS",
clicksendsms: "ClickSend SMS",
lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)",
apprise: "Apprise (Podržava preko 50 usluga za obavijesti)",
pushbullet: "Pushbullet",
line: "LINE",
mattermost: "Mattermost",
@ -307,4 +307,5 @@ export default {
"Showing {from} to {to} of {count} records": "Prikaz zapisa {from}-{to} od sveukupno {count}",
steamApiKeyDescription: "Za praćenje Steam poslužitelja za igru, potrebno je imati Steam Web-API ključ. Možete registrirati vlastiti ključ ovdje: ",
"Current User": "Trenutni korisnik",
recent: "Nedavno",
};

View file

@ -77,6 +77,17 @@
<font-awesome-icon icon="save" />
{{ $t("Switch to Dark Theme") }}
</button>
<button class="btn btn-secondary me-2" @click="changeTagsVisibilty(!tagsVisible)">
<template v-if="tagsVisible">
<font-awesome-icon icon="eye-slash" />
{{ $t("Hide Tags") }}
</template>
<template v-else>
<font-awesome-icon icon="eye" />
{{ $t("Show Tags") }}
</template>
</button>
</div>
</div>
@ -292,6 +303,10 @@ export default {
return this.config.statusPageTheme;
},
tagsVisible() {
return this.config.statusPageTags
},
logoClass() {
if (this.editMode) {
return {
@ -472,6 +487,25 @@ export default {
changeTheme(name) {
this.config.statusPageTheme = name;
},
changeTagsVisibilty(newState) {
this.config.statusPageTags = newState;
// On load, the status page will not include tags if it's not enabled for security reasons
// Which means if we enable tags, it won't show in the UI until saved
// So we have this to enhance UX and load in the tags from the authenticated source instantly
this.$root.publicGroupList = this.$root.publicGroupList.map((group) => {
return {
...group,
monitorList: group.monitorList.map((monitor) => {
// We only include the tags if visible so we can reuse the logic to hide the tags on disable
return {
...monitor,
tags: newState ? this.$root.monitorList[monitor.id].tags : []
}
})
}
});
},
/**
* Crop Success

View file

@ -1,4 +1,125 @@
const { genSecret, sleep } = require("../src/util");
const utilServerRewire = require("../server/util-server");
describe("Test parseCertificateInfo", () => {
it("should handle undefined", async () => {
const parseCertificateInfo = utilServerRewire.__get__("parseCertificateInfo");
const info = parseCertificateInfo(undefined);
expect(info).toEqual(undefined);
}, 5000);
it("should handle normal cert chain", async () => {
const parseCertificateInfo = utilServerRewire.__get__("parseCertificateInfo");
const chain1 = {
fingerprint: "CF:2C:F3:6A:FE:6B:10:EC:44:77:C8:95:BB:96:2E:06:1F:0E:15:DA",
valid_from: "Oct 22 12:00:00 2013 GMT",
valid_to: "Oct 22 12:00:00 2028 GMT",
subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net",
};
const chain2 = {
fingerprint: "A0:31:C4:67:82:E6:E6:C6:62:C2:C8:7C:76:DA:9A:A6:2C:CA:BD:8E",
valid_from: "Oct 22 12:00:00 2013 GMT",
valid_to: "Oct 22 12:00:00 2028 GMT",
subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net",
};
const chain3 = {
fingerprint: "5F:B7:EE:06:33:E2:59:DB:AD:0C:4C:9A:E6:D3:8F:1A:61:C7:DC:25",
valid_from: "Oct 22 12:00:00 2013 GMT",
valid_to: "Oct 22 12:00:00 2028 GMT",
subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net",
};
chain1.issuerCertificate = chain2;
chain2.issuerCertificate = chain3;
chain3.issuerCertificate = chain3;
const info = parseCertificateInfo(chain1);
expect(chain1).toEqual(info);
}, 5000);
it("should handle cert chain with strange circle", async () => {
const parseCertificateInfo = utilServerRewire.__get__("parseCertificateInfo");
const chain1 = {
fingerprint: "CF:2C:F3:6A:FE:6B:10:EC:44:77:C8:95:BB:96:2E:06:1F:0E:15:DA",
valid_from: "Oct 22 12:00:00 2013 GMT",
valid_to: "Oct 22 12:00:00 2028 GMT",
subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net",
};
const chain2 = {
fingerprint: "A0:31:C4:67:82:E6:E6:C6:62:C2:C8:7C:76:DA:9A:A6:2C:CA:BD:8E",
valid_from: "Oct 22 12:00:00 2013 GMT",
valid_to: "Oct 22 12:00:00 2028 GMT",
subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net",
};
const chain3 = {
fingerprint: "5F:B7:EE:06:33:E2:59:DB:AD:0C:4C:9A:E6:D3:8F:1A:61:C7:DC:25",
valid_from: "Oct 22 12:00:00 2013 GMT",
valid_to: "Oct 22 12:00:00 2028 GMT",
subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net",
};
const chain4 = {
fingerprint: "haha",
valid_from: "Oct 22 12:00:00 2013 GMT",
valid_to: "Oct 22 12:00:00 2028 GMT",
subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net",
};
chain1.issuerCertificate = chain2;
chain2.issuerCertificate = chain3;
chain3.issuerCertificate = chain4;
chain4.issuerCertificate = chain2;
const info = parseCertificateInfo(chain1);
expect(chain1).toEqual(info);
}, 5000);
it("should handle cert chain with last undefined (should be happen in real, but just in case)", async () => {
const parseCertificateInfo = utilServerRewire.__get__("parseCertificateInfo");
const chain1 = {
fingerprint: "CF:2C:F3:6A:FE:6B:10:EC:44:77:C8:95:BB:96:2E:06:1F:0E:15:DA",
valid_from: "Oct 22 12:00:00 2013 GMT",
valid_to: "Oct 22 12:00:00 2028 GMT",
subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net",
};
const chain2 = {
fingerprint: "A0:31:C4:67:82:E6:E6:C6:62:C2:C8:7C:76:DA:9A:A6:2C:CA:BD:8E",
valid_from: "Oct 22 12:00:00 2013 GMT",
valid_to: "Oct 22 12:00:00 2028 GMT",
subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net",
};
const chain3 = {
fingerprint: "5F:B7:EE:06:33:E2:59:DB:AD:0C:4C:9A:E6:D3:8F:1A:61:C7:DC:25",
valid_from: "Oct 22 12:00:00 2013 GMT",
valid_to: "Oct 22 12:00:00 2028 GMT",
subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net",
};
const chain4 = {
fingerprint: "haha",
valid_from: "Oct 22 12:00:00 2013 GMT",
valid_to: "Oct 22 12:00:00 2028 GMT",
subjectaltname: "DNS:www.example.org, DNS:example.com, DNS:example.edu, DNS:example.net, DNS:example.org, DNS:www.example.com, DNS:www.example.edu, DNS:www.example.net",
};
chain1.issuerCertificate = chain2;
chain2.issuerCertificate = chain3;
chain3.issuerCertificate = chain4;
chain4.issuerCertificate = undefined;
const info = parseCertificateInfo(chain1);
expect(chain1).toEqual(info);
}, 5000);
});
describe("Test genSecret", () => {
@ -42,3 +163,4 @@ describe("Test reset-password", () => {
await require("../extra/reset-password").main();
}, 120000);
});