Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { GET, POST } from "@/app/api/project-thumbnail/route";
|
|
|
|
function missingThumbnailRequest(url: string, headers?: HeadersInit) {
|
|
return new Request(`${url}/api/project-thumbnail?projectId=missing-thumbnail`, { headers });
|
|
}
|
|
|
|
describe("project thumbnail request origins", () => {
|
|
it("allows same-origin requests on a public HTTPS host", async () => {
|
|
const response = await GET(missingThumbnailRequest("https://projects.example.test", {
|
|
Origin: "https://projects.example.test",
|
|
"Sec-Fetch-Site": "same-origin",
|
|
}));
|
|
|
|
expect(response.status).toBe(404);
|
|
});
|
|
|
|
it("uses forwarded host and protocol behind a TLS reverse proxy", async () => {
|
|
const response = await GET(missingThumbnailRequest("http://localhost:3000", {
|
|
Origin: "https://projects.example.test",
|
|
"Sec-Fetch-Site": "same-origin",
|
|
"X-Forwarded-Host": "projects.example.test",
|
|
"X-Forwarded-Proto": "https",
|
|
}));
|
|
|
|
expect(response.status).toBe(404);
|
|
});
|
|
|
|
it("rejects a different origin", async () => {
|
|
const response = await GET(missingThumbnailRequest("https://projects.example.test", {
|
|
Origin: "https://other.example.test",
|
|
"Sec-Fetch-Site": "cross-site",
|
|
}));
|
|
|
|
expect(response.status).toBe(403);
|
|
});
|
|
|
|
it("allows same-origin uploads to proceed to request validation", async () => {
|
|
const response = await POST(new Request("https://projects.example.test/api/project-thumbnail", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
Origin: "https://projects.example.test",
|
|
"Sec-Fetch-Site": "same-origin",
|
|
},
|
|
body: JSON.stringify({}),
|
|
}));
|
|
|
|
expect(response.status).toBe(400);
|
|
await expect(response.json()).resolves.toEqual({ error: "Invalid thumbnail request" });
|
|
});
|
|
});
|