generated from jric11/baseProject
30 lines
3.1 KiB
Python
30 lines
3.1 KiB
Python
from application_harness import Application
|
|
app=Application();checks=[]
|
|
def check(ok,message):
|
|
if not ok:raise AssertionError(message)
|
|
checks.append(message);print('PASS: '+message)
|
|
def expect(response,status,message):
|
|
check(response[0]==status,message+' (HTTP '+str(response[0])+')');return response[1]
|
|
try:
|
|
ids=app.fixture('tenantSeed');club=ids['clubA'];app.login('membera@example.test','Tenant test password 123!')
|
|
for text,label in [('界'*3000,'Three-thousand-character Unicode message'),('😀'*8000,'Eight-thousand-character four-byte message')]:
|
|
expect(app.post('Roster.tickets',step='openTicket',club_serial=club,subject=label,message=text),200,label+' can be submitted')
|
|
ticket=app.fixture('inspect')['club_tickets'][-1]['ticket_serial'];body=app.request(f'/main.php?Xaction=Roster.tickets&club_serial={club}&ticket_serial={ticket}')[1]
|
|
check(text.encode() in body,label+' is preserved without truncation')
|
|
ticket=app.fixture('inspect')['club_tickets'][-1]['ticket_serial']
|
|
expect(app.post('Roster.tickets',step='reply',club_serial=club,ticket_serial=ticket,message='😀'*8000),200,'Unicode reply accepts the same character boundary')
|
|
for text,label in [('x'*8001,'Oversized ASCII message'),('😀'*8001,'Oversized Unicode message')]:
|
|
before=app.fixture('fingerprints');body=expect(app.post('Roster.tickets',step='openTicket',club_serial=club,subject='Too long',message=text),422,label+' gets a field validation error')
|
|
check(b'Message must be 8000 characters or fewer.' in body,label+' explains the supported limit')
|
|
after=app.fixture('fingerprints');check(after['club_tickets']==before['club_tickets'] and after['club_ticket_messages']==before['club_ticket_messages'],label+' creates no ticket or partial message')
|
|
before=app.fixture('fingerprints');expect(app.post('Roster.tickets',step='reply',club_serial=club,ticket_serial=ticket,message='😀'*8001),422,'Oversized Unicode reply is rejected')
|
|
check(app.fixture('fingerprints')['club_ticket_messages']==before['club_ticket_messages'],'Rejected reply leaves message history unchanged')
|
|
expect(app.post('Roster.tickets',step='openTicket',club_serial=club,subject='Hard limit',message='x'*65537),400,'Hard transport ceiling still rejects extreme ticket bodies')
|
|
expect(app.post('Roster.tickets',step='openTicket',club_serial=club,subject='Array',**{'message[]':'bad'}),400,'Array-shaped ticket body is rejected')
|
|
expect(app.post('Roster.tickets',step='openTicket',club_serial=club,subject='x'*8193,message='Normal'),400,'Larger message allowance does not widen other field byte limits')
|
|
expect(app.post('Roster.workspace',step='club',club_serial=club,club_name='x'*9000),400,'Larger message allowance does not widen other routes')
|
|
response=app.request('/main.php?Xaction=Roster.tickets&user_email%5B%5D=bad',data={'action':'Roster.tickets','csrf_token':app.token,'user_email':'valid@example.test'},ajax=True)
|
|
expect(response,400,'A POST field cannot hide an array-shaped query field')
|
|
finally:app.close()
|
|
print(str(len(checks))+' ticket repair HTTP checks passed.')
|