mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 11:56:01 +01:00 
			
		
		
		
	test(routes/login): add initial test via supertest for failed login
This commit is contained in:
		
							
								
								
									
										36
									
								
								src/routes/login.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/routes/login.spec.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					import { beforeAll, describe, it } from "vitest";
 | 
				
			||||||
 | 
					import supertest from "supertest";
 | 
				
			||||||
 | 
					import { initializeTranslations } from "../services/i18n.js";
 | 
				
			||||||
 | 
					import type { Application, Request, Response, NextFunction } from "express";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					let app: Application;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe("Login Route test", () => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    beforeAll(async () => {
 | 
				
			||||||
 | 
					        initializeTranslations();
 | 
				
			||||||
 | 
					        app = (await import("../app.js")).default;
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it("return a 401 status, when login fails with wrong password", async () => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        await supertest(app)
 | 
				
			||||||
 | 
					            .post("/login")
 | 
				
			||||||
 | 
					            .send({ password: "fakePassword" })
 | 
				
			||||||
 | 
					            .expect(401)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // TriliumNextTODO: how to handle different configs here? e.g. TOTP, or different cookieMaxAge from config.ini
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it("sets correct Expires, when 'Remember Me' is ticked", async () => {
 | 
				
			||||||
 | 
					        await supertest(app)
 | 
				
			||||||
 | 
					            .post("/login")
 | 
				
			||||||
 | 
					            .expect(302)
 | 
				
			||||||
 | 
					            .expect("Set-Cookie", "trilium.sid=trilium.sid; Path=/; Expires=TODO");
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
		Reference in New Issue
	
	Block a user