@@ -107,13 +107,13 @@ describe('domain-verification helpers', () => {
107107
108108 it ( 'verifies when the exact value is published' , async ( ) => {
109109 mockResolveTxt . mockResolvedValue ( [ [ EXPECTED ] ] )
110- await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( true )
110+ await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( 'present' )
111111 } )
112112
113113 it ( 'joins a value split across 255-char chunks before comparing' , async ( ) => {
114114 const midpoint = Math . floor ( EXPECTED . length / 2 )
115115 mockResolveTxt . mockResolvedValue ( [ [ EXPECTED . slice ( 0 , midpoint ) , EXPECTED . slice ( midpoint ) ] ] )
116- await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( true )
116+ await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( 'present' )
117117 } )
118118
119119 it ( 'finds the match among unrelated TXT records on the same host' , async ( ) => {
@@ -122,37 +122,41 @@ describe('domain-verification helpers', () => {
122122 [ 'facebook-domain-verification=abc123' ] ,
123123 [ EXPECTED ] ,
124124 ] )
125- await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( true )
125+ await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( 'present' )
126126 } )
127127
128128 it ( 'tolerates padding a DNS panel added around the value' , async ( ) => {
129129 mockResolveTxt . mockResolvedValue ( [ [ ` ${ EXPECTED } ` ] ] )
130- await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( true )
130+ await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( 'present' )
131131 } )
132132
133133 it ( 'rejects a near-miss value (no partial or prefix match)' , async ( ) => {
134134 mockResolveTxt . mockResolvedValue ( [ [ `${ EXPECTED } extra` ] , [ EXPECTED . slice ( 0 , - 1 ) ] ] )
135- await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( false )
135+ await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( 'absent' )
136136 } )
137137
138138 it ( 'rejects another org token published on the same host' , async ( ) => {
139139 mockResolveTxt . mockResolvedValue ( [ [ buildTxtRecordValue ( 'someone-elses-token' ) ] ] )
140- await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( false )
140+ await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( 'absent' )
141141 } )
142142
143- it ( 'returns false (never throws) when the record is absent ' , async ( ) => {
143+ it ( 'reports absent (never throws) when the record is not published ' , async ( ) => {
144144 mockResolveTxt . mockRejectedValue ( Object . assign ( new Error ( 'no data' ) , { code : 'ENODATA' } ) )
145- await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( false )
145+ await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( 'absent' )
146146 } )
147147
148- it ( 'returns false (never throws) when resolution fails for an infrastructure reason' , async ( ) => {
148+ /**
149+ * Distinct from `absent`: our resolver failed, so we learned nothing about the
150+ * admin's DNS and must not tell them their record is missing.
151+ */
152+ it ( 'reports unavailable when resolution fails for an infrastructure reason' , async ( ) => {
149153 mockResolveTxt . mockRejectedValue ( Object . assign ( new Error ( 'timeout' ) , { code : 'ETIMEOUT' } ) )
150- await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( false )
154+ await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( 'unavailable' )
151155 } )
152156
153- it ( 'returns false when the host has no TXT records at all' , async ( ) => {
157+ it ( 'reports absent when the host has no TXT records at all' , async ( ) => {
154158 mockResolveTxt . mockResolvedValue ( [ ] )
155- await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( false )
159+ await expect ( checkDomainTxtRecord ( 'acme.com' , TOKEN ) ) . resolves . toBe ( 'absent' )
156160 } )
157161 } )
158162} )
0 commit comments