mirror of
https://github.com/better-auth/better-auth.git
synced 2026-08-23 17:58:47 -05:00
fix(sync): align tests with next contracts
This commit is contained in:
+18
-5
@@ -1,5 +1,11 @@
|
||||
import { relations, sql } from "drizzle-orm";
|
||||
import { sqliteTable, text, integer, index } from "drizzle-orm/sqlite-core";
|
||||
import {
|
||||
sqliteTable,
|
||||
text,
|
||||
integer,
|
||||
index,
|
||||
uniqueIndex,
|
||||
} from "drizzle-orm/sqlite-core";
|
||||
|
||||
export const users = sqliteTable("users", {
|
||||
id: text("id").primaryKey(),
|
||||
@@ -43,7 +49,8 @@ export const accounts = sqliteTable(
|
||||
"accounts",
|
||||
{
|
||||
id: text("id").primaryKey(),
|
||||
accountId: text("account_id").notNull(),
|
||||
issuer: text("issuer").notNull(),
|
||||
providerAccountId: text("provider_account_id").notNull(),
|
||||
providerId: text("provider_id").notNull(),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
@@ -66,7 +73,13 @@ export const accounts = sqliteTable(
|
||||
.$onUpdate(() => /* @__PURE__ */ new Date())
|
||||
.notNull(),
|
||||
},
|
||||
(table) => [index("accounts_userId_idx").on(table.userId)],
|
||||
(table) => [
|
||||
uniqueIndex("accounts_issuer_providerAccountId_uidx").on(
|
||||
table.issuer,
|
||||
table.providerAccountId,
|
||||
),
|
||||
index("accounts_userId_idx").on(table.userId),
|
||||
],
|
||||
);
|
||||
|
||||
export const verifications = sqliteTable(
|
||||
@@ -103,14 +116,14 @@ export const usersRelations = relations(users, ({ many }) => ({
|
||||
}));
|
||||
|
||||
export const sessionsRelations = relations(sessions, ({ one }) => ({
|
||||
users: one(users, {
|
||||
user: one(users, {
|
||||
fields: [sessions.userId],
|
||||
references: [users.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const accountsRelations = relations(accounts, ({ one }) => ({
|
||||
users: one(users, {
|
||||
user: one(users, {
|
||||
fields: [accounts.userId],
|
||||
references: [users.id],
|
||||
}),
|
||||
|
||||
@@ -908,7 +908,6 @@ model Directory_user {
|
||||
});
|
||||
|
||||
expect(schema.code).toContain('slug: text("slug").notNull().unique()');
|
||||
expect(schema.code).not.toContain("uniqueIndex");
|
||||
expect(schema.code).not.toContain("slug_uidx");
|
||||
});
|
||||
|
||||
|
||||
@@ -1718,7 +1718,7 @@ describe("SAML SSO", async () => {
|
||||
["good-then-bad", [mockIdpSigningCert, unrelatedCertificate]],
|
||||
])("should validate SAML response when signing cert matches any in the array (%s)", async (_name, certs) => {
|
||||
const { auth, signInWithTestUser } = await getTestInstance({
|
||||
plugins: [sso()],
|
||||
plugins: [sso({ saml: { enableInResponseToValidation: false } })],
|
||||
});
|
||||
|
||||
const { headers } = await signInWithTestUser();
|
||||
@@ -1850,7 +1850,7 @@ describe("SAML SSO", async () => {
|
||||
|
||||
it("should initiate SAML login and validate RelayState", async () => {
|
||||
const { auth, signInWithTestUser } = await getTestInstance({
|
||||
plugins: [sso()],
|
||||
plugins: [sso({ saml: { enableInResponseToValidation: false } })],
|
||||
});
|
||||
|
||||
const { headers } = await signInWithTestUser();
|
||||
@@ -1992,7 +1992,12 @@ describe("SAML SSO", async () => {
|
||||
|
||||
it("should initiate SAML login and signup user when disableImplicitSignUp is true but requestSignup is explicitly enabled", async () => {
|
||||
const { auth, signInWithTestUser } = await getTestInstance({
|
||||
plugins: [sso({ disableImplicitSignUp: true })],
|
||||
plugins: [
|
||||
sso({
|
||||
disableImplicitSignUp: true,
|
||||
saml: { enableInResponseToValidation: false },
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const { headers } = await signInWithTestUser();
|
||||
@@ -6939,7 +6944,7 @@ describe("SAML SSO Hardening", () => {
|
||||
describe("RelayState controls post-auth redirect", () => {
|
||||
it("should redirect to RelayState callbackURL after authentication", async () => {
|
||||
const { auth, signInWithTestUser } = await getTestInstance({
|
||||
plugins: [sso()],
|
||||
plugins: [sso({ saml: { enableInResponseToValidation: false } })],
|
||||
});
|
||||
const { headers } = await signInWithTestUser();
|
||||
|
||||
@@ -7063,6 +7068,7 @@ describe("SAML SSO Hardening", () => {
|
||||
sso({
|
||||
saml: {
|
||||
allowIdpInitiated: true,
|
||||
enableInResponseToValidation: false,
|
||||
},
|
||||
}),
|
||||
],
|
||||
@@ -7115,6 +7121,7 @@ describe("SAML SSO Hardening", () => {
|
||||
sso({
|
||||
saml: {
|
||||
allowIdpInitiated: true,
|
||||
enableInResponseToValidation: false,
|
||||
idpInitiatedCallbackUrl: `${frontendOrigin}/global-idp-redirect`,
|
||||
},
|
||||
}),
|
||||
@@ -7167,6 +7174,7 @@ describe("SAML SSO Hardening", () => {
|
||||
sso({
|
||||
saml: {
|
||||
allowIdpInitiated: true,
|
||||
enableInResponseToValidation: false,
|
||||
idpInitiatedCallbackUrl: `${frontendOrigin}/global-idp-redirect`,
|
||||
},
|
||||
}),
|
||||
@@ -7397,6 +7405,7 @@ describe("SAML SSO Hardening", () => {
|
||||
sso({
|
||||
saml: {
|
||||
allowIdpInitiated: true,
|
||||
enableInResponseToValidation: false,
|
||||
idpInitiatedCallbackUrl: "http://attacker.com/malicious",
|
||||
},
|
||||
}),
|
||||
@@ -7412,8 +7421,6 @@ describe("SAML SSO Hardening", () => {
|
||||
samlConfig: {
|
||||
entryPoint: "http://localhost:8081/api/sso/saml2/idp/post",
|
||||
cert: certificate,
|
||||
callbackUrl:
|
||||
"http://localhost:3000/api/auth/sso/saml2/callback/unsafe-provider",
|
||||
idpMetadata: { metadata: idpMetadata },
|
||||
spMetadata: { metadata: spMetadata },
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user