gs1 / GS1DL-resolver-testsuite

A test suite against which a resolver's conformance with the GS1 Digital Link spec can be assessed
Apache License 2.0
6 stars 1 forks source link

methodsCheck: possible undefined object accessed #13

Closed JohannesFluegel closed 3 years ago

JohannesFluegel commented 3 years ago

https://github.com/gs1/GS1DL-resolver-testsuite/blob/master/GS1DigitalLinkResolverTestSuite.js#L275

if (((data.result['access-control-allow-methods'].indexOf('GET') > -1) || //...

data.result['access-control-allow-methods'] might be undefined, then the scripts exits with the error TypeError: data.result['access-control-allow-methods'] is undefined.

And by the way: do you want to check if ANY of these methods work or rather ALL of them? Currently you test ANY.

philarcher commented 3 years ago

Thanks again @JohannesFluegel. Really not sure why I checked those GET, HEAD and OPTIONS with OR and not AND. Now changed.

You'll no doubt have noticed that the standard of code in the test suite is not the highest. That's because I'm a happy amateur cf. Nick Lansley who is the pro developer who has written almost all the code for the resolver. The idea is that he shouldn't mark his own homework - although I have had to all for help on a couple of things! Any and all improvements welcome (feel free to write a PR. Please tag me so I know it's there).