comparison Plugins/DicomWeb/Run.py @ 532:f96c023ce523

dicom-web X-Forwarded headers
author Alain Mazy <am@osimis.io>
date Mon, 24 Apr 2023 10:43:27 +0200
parents 933fe1bbce4f
children c5291d97ed54
comparison
equal deleted inserted replaced
531:8a920ab91cf4 532:f96c023ce523
1646 self.assertLessEqual(abs(GetLinear(0x10 * rs + ri, 127, 256) - im.getpixel((1, 0))), 1) 1646 self.assertLessEqual(abs(GetLinear(0x10 * rs + ri, 127, 256) - im.getpixel((1, 0))), 1)
1647 self.assertLessEqual(abs(GetLinear(0x20 * rs + ri, 127, 256) - im.getpixel((0, 1))), 1) 1647 self.assertLessEqual(abs(GetLinear(0x20 * rs + ri, 127, 256) - im.getpixel((0, 1))), 1)
1648 self.assertLessEqual(abs(GetLinear(0x30 * rs + ri, 127, 256) - im.getpixel((1, 1))), 1) 1648 self.assertLessEqual(abs(GetLinear(0x30 * rs + ri, 127, 256) - im.getpixel((1, 1))), 1)
1649 1649
1650 1650
1651 def test_forwarded_headers(self):
1652 study = UploadInstance(ORTHANC, 'ColorTestImageJ.dcm')['ParentStudy']
1653 studyId = DoGet(ORTHANC, '/studies/%s' % study)['MainDicomTags']['StudyInstanceUID']
1654
1655 m = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % studyId)
1656 self.assertIn("http://localhost:8042/dicom-web", m[0][u'7FE00010']['BulkDataURI'])
1657
1658 m = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % studyId, headers= {
1659 'host': 'my-domain'
1660 })
1661 self.assertIn("http://my-domain/dicom-web", m[0][u'7FE00010']['BulkDataURI'])
1662
1663 m = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % studyId, headers= {
1664 'forwarded': 'host=my-domain;proto=https'
1665 })
1666 self.assertIn("https://my-domain/dicom-web", m[0][u'7FE00010']['BulkDataURI'])
1667
1668 if IsPluginVersionAbove(ORTHANC, "dicom-web", 1, 13, 1):
1669 m = DoGet(ORTHANC, '/dicom-web/studies/%s/metadata' % studyId, headers= {
1670 'X-Forwarded-Host': 'my-domain',
1671 'X-Forwarded-Proto': 'https'
1672 })
1673 self.assertIn("https://my-domain/dicom-web", m[0][u'7FE00010']['BulkDataURI'])
1674
1675
1676
1651 try: 1677 try:
1652 print('\nStarting the tests...') 1678 print('\nStarting the tests...')
1653 unittest.main(argv = [ sys.argv[0] ] + args.options) 1679 unittest.main(argv = [ sys.argv[0] ] + args.options)
1654 1680
1655 finally: 1681 finally: