@@ -4,6 +4,7 @@ import { admin } from 'better-auth/plugins'
44import { describe , expect , it } from 'vitest'
55import { DISPOSABLE_EMAIL_ERROR_CODE } from '@/lib/auth/constants'
66import { refuseDisposableAccountEmail } from '@/lib/auth/disposable-email-gate'
7+ import { configuredSsoPlugin } from '@/lib/auth/sso/plugin'
78
89/**
910 * A real Better Auth instance wired the way `auth.ts` wires the gate, so the endpoint path each
@@ -56,14 +57,20 @@ describe('refuseDisposableAccountEmail', () => {
5657 expect ( result . user . email ) . toBe ( 'jane@mailinator.com' )
5758 } )
5859
59- it . each ( [
60- '/sso/callback/:providerId' ,
61- '/sso/callback' ,
62- '/sso/saml2/callback/:providerId' ,
63- '/sso/saml2/sp/acs/:providerId' ,
64- ] ) ( 'admits an SSO just-in-time account created at %s' , async ( path ) => {
65- await expect ( refuseDisposableAccountEmail ( 'jane@mailinator.com' , path ) ) . resolves . toBeUndefined ( )
66- } )
60+ /**
61+ * Better Auth dispatches with an endpoint's declared path, so the SSO plugin's own callback
62+ * endpoints name the paths a just-in-time creation reports. No IdP is driven here.
63+ */
64+ const { callbackSSO, callbackSSOShared, callbackSSOSAML, acsEndpoint } =
65+ configuredSsoPlugin . endpoints
66+ it . each ( [ callbackSSO . path , callbackSSOShared . path , callbackSSOSAML . path , acsEndpoint . path ] ) (
67+ 'admits any domain at the SSO plugin callback path %s' ,
68+ async ( path ) => {
69+ await expect (
70+ refuseDisposableAccountEmail ( 'jane@mailinator.com' , path )
71+ ) . resolves . toBeUndefined ( )
72+ }
73+ )
6774
6875 it . each ( [ undefined , '/sign-up/email' , '/callback/:id' , '/oauth2/callback/:providerId' ] ) (
6976 'refuses a disposable domain created at %s' ,
0 commit comments