node-saml / node-saml

A SAML library not dependent on any frameworks that runs in Node.
MIT License
93 stars 63 forks source link

[BUG] Issuer is Now Required at Runtime But Not During Type Checking #89

Closed sadikinfosec closed 2 years ago

sadikinfosec commented 2 years ago

To Reproduce

I adjusted the "get Urls" test from the samlTests.spec.ts file to omit the issuer (mimicking our app's previous setup), and got a runtime error of "issuer is required" when it was run

diff --git a/test/samlTests.spec.ts b/test/samlTests.spec.ts
index 815691b..0fed2df 100644
--- a/test/samlTests.spec.ts
+++ b/test/samlTests.spec.ts
@@ -17,7 +17,7 @@ describe("SAML.js", function () {
         entryPoint: "https://exampleidp.com/path?key=value",
         logoutUrl: "https://exampleidp.com/path?key=value",
         cert: FAKE_CERT,
-        issuer: "onesaml_login",
+        // issuer: "onesaml_login",
       });
       req = {
         protocol: "https",
1) SAML.js
       get Urls
         "before each" hook for "calls callback with original query string":
     TypeError: issuer is required
      at assertRequired (src/utility.ts:2:667)
      at SAML.initialize (src/saml.ts:2:4711)
      at new SAML (src/saml.ts:2:4242)
      at Context.<anonymous> (test/samlTests.spec.ts:16:14)
      at processImmediate (internal/timers.js:464:21)

Expected behavior The TSC should've have failed beforehand when checking types instead

Environment

cjbarth commented 2 years ago

This is addressing gaps in #61