forked from bitwarden/clients
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Check if both Cozy blue or Cozy gl exists
Also refactored a little the CozySanitizeUrlService.
- Loading branch information
Showing
6 changed files
with
58 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
29 changes: 14 additions & 15 deletions
29
...rc/popup/accounts/login.component.spec.ts → .../services/cozySanitizeUrl.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,74 @@ | ||
import { sanitizeUrlInput } from "../../auth/popup/login.component.functions"; | ||
import { CozySanitizeUrlService } from "../services/cozySanitizeUrl.service"; | ||
import { CozySanitizeUrlService } from "./cozySanitizeUrl.service"; | ||
|
||
describe("url input", () => { | ||
const cozySanitizeUrlService = new CozySanitizeUrlService(); | ||
|
||
it("should return undefined if the input is empty", () => { | ||
const inputUrl = ""; | ||
expect(() => { | ||
sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
}).toThrow(new Error("cozyUrlRequired")); | ||
}); | ||
it("should return undefined if the input is an email", () => { | ||
const inputUrl = "claude@cozycloud.cc"; | ||
expect(() => { | ||
sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
}).toThrow(new Error("noEmailAsCozyUrl")); | ||
}); | ||
it("should return the url without the app slug if present", () => { | ||
const inputUrl = "claude-drive.mycozy.cloud"; | ||
const url = sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
const url = cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
expect(url).toEqual("https://claude.mycozy.cloud"); | ||
}); | ||
it("should return the url with the default domain if missing", () => { | ||
const inputUrl = "claude-drive"; | ||
const url = sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
const url = cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
expect(url).toEqual("https://claude.mycozy.cloud"); | ||
}); | ||
it("should return the url with the default scheme if missing", () => { | ||
const inputUrl = "claude.mycozy.cloud"; | ||
const url = sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
const url = cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
expect(url).toEqual("https://claude.mycozy.cloud"); | ||
}); | ||
it("should return the url if the input is correct", () => { | ||
const inputUrl = "https://claude.mycozy.cloud"; | ||
const url = sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
const url = cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
expect(url).toEqual("https://claude.mycozy.cloud"); | ||
}); | ||
it("should accept local url", () => { | ||
const inputUrl = "http://claude.cozy.tools:8080"; | ||
const url = sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
const url = cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
expect(url).toEqual("http://claude.cozy.tools:8080"); | ||
}); | ||
it("should not try to remove slug if present and url has a custom domain", () => { | ||
const inputUrl = "claude-drive.on-premise.cloud"; | ||
const url = sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
const url = cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
expect(url).toEqual("https://claude-drive.on-premise.cloud"); | ||
}); | ||
it("should return the correct url if domains contains a dash", () => { | ||
const inputUrl = "claude.on-premise.cloud"; | ||
const url = sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
const url = cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
expect(url).toEqual("https://claude.on-premise.cloud"); | ||
}); | ||
it("should return the correct url if domains contains a dash and cozy is installed on domain root", () => { | ||
const inputUrl = "https://on-premise.cloud"; | ||
const url = sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
const url = cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
expect(url).toEqual("https://on-premise.cloud"); | ||
}); | ||
it(`should throw if user write 'mycosy' instead of 'mycozy'`, () => { | ||
const inputUrl = "https://claude.mycosy.cloud"; | ||
expect(() => { | ||
sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
}).toThrow(new Error("hasMispelledCozy")); | ||
}); | ||
it(`should accept real '*cosy*' url`, () => { | ||
const inputUrl = "https://claude.realdomaincosy.cloud"; | ||
const url = sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
const url = cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
expect(url).toEqual("https://claude.realdomaincosy.cloud"); | ||
}); | ||
it(`should remove trailing / in url`, () => { | ||
const inputUrl = "https://claude.realdomaincosy.cloud/"; | ||
const url = sanitizeUrlInput(inputUrl, cozySanitizeUrlService); | ||
const url = cozySanitizeUrlService.sanitizeUrlInput(inputUrl); | ||
expect(url).toEqual("https://claude.realdomaincosy.cloud"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters