|
| 1 | +import { expect } from "chai"; |
| 2 | +import { AccessPoint } from "./AccessPoint"; |
| 3 | + |
| 4 | +const scl = new DOMParser().parseFromString( |
| 5 | + `<SCL xmlns="http://www.iec.ch/61850/2003/SCL" > |
| 6 | + <IED name="IED1"> |
| 7 | + <AccessPoint name="AP1" router="false" clock="false" kdc="false"> |
| 8 | + <Services /> |
| 9 | + <Server timeout="30"> |
| 10 | + <Authentication /> |
| 11 | + <LDevice inst="lDevice1"> |
| 12 | + <LN0 lnClass="LLN0" inst="" lnType="LLN0" /> |
| 13 | + <LN lnClass="MMXU" inst="1" lnType="MMXU" /> |
| 14 | + <LN lnClass="MMXU" inst="2" lnType="MMXU" /> |
| 15 | + </LDevice> |
| 16 | + <LDevice inst="lDevice2"> |
| 17 | + <LN0 lnClass="LLN0" inst="" lnType="LLN0" /> |
| 18 | + <LN lnClass="MMXU" inst="1" lnType="MMXU" /> |
| 19 | + </LDevice> |
| 20 | + <Association iedName="IED3" ldInst="lDevice2" lnClass="LLN0" lnInst="" kind="pre-established" associationId="someId" /> |
| 21 | + <Association iedName="IED3" ldInst="lDevice2" lnClass="MMXU" lnInst="1" kind="predefined" associationId="someId" /> |
| 22 | + <Association desc="" iedName="IED3" ldInst="lDevice2" lnClass="MMXU" lnInst="2" kind="predefined" associationId="someId" /> |
| 23 | + <Association desc="" iedName="IED3" ldInst="lDevice2" lnClass="MMXU" lnInst="2" kind="predefined" associationId="someId" /> |
| 24 | + </Server> |
| 25 | + <ServerAt apName="AP1" /> |
| 26 | + <GOOSESecurity name="goose1" serialNumber="1" xferNumber="somexfer1" > |
| 27 | + <Subject commonName="none" idHierarchy="someId" /> |
| 28 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 29 | + </GOOSESecurity> |
| 30 | + <GOOSESecurity name="goose3" serialNumber="3" xferNumber="somexfer3" > |
| 31 | + <Subject commonName="none" idHierarchy="someId" /> |
| 32 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 33 | + </GOOSESecurity> |
| 34 | + <GOOSESecurity name="goose2" serialNumber="2" xferNumber="somexfer2" > |
| 35 | + <Subject commonName="none" idHierarchy="someId" /> |
| 36 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 37 | + </GOOSESecurity> |
| 38 | + <SMVSecurity name="smv1" serialNumber="1" xferNumber="somexfer1" > |
| 39 | + <Subject commonName="none" idHierarchy="someId" /> |
| 40 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 41 | + </SMVSecurity> |
| 42 | + <SMVSecurity name="smv3" serialNumber="3" xferNumber="somexfer3" > |
| 43 | + <Subject commonName="none" idHierarchy="someId" /> |
| 44 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 45 | + </SMVSecurity> |
| 46 | + <SMVSecurity name="smv2" serialNumber="2" xferNumber="somexfer2" > |
| 47 | + <Subject commonName="none" idHierarchy="someId" /> |
| 48 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 49 | + </SMVSecurity> |
| 50 | + <SMVSecurity xferNumber="somexfer2" > |
| 51 | + <Subject commonName="none" idHierarchy="someId" /> |
| 52 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 53 | + </SMVSecurity> |
| 54 | + <SMVSecurity name="smv13" serialNumber="13" xferNumber="somexfer2" > |
| 55 | + <Subject commonName="none" idHierarchy="someId" /> |
| 56 | + </SMVSecurity> |
| 57 | + <SMVSecurity name="14" serialNumber="14" xferNumber="somexfer2" > |
| 58 | + <Subject commonName="none" idHierarchy="someId" /> |
| 59 | + <IssuerName commonName="none" /> |
| 60 | + </SMVSecurity> |
| 61 | + </AccessPoint> |
| 62 | + </IED> |
| 63 | + <IED name="IED2"> |
| 64 | + <AccessPoint name="AP1"> |
| 65 | + <Services /> |
| 66 | + <Server> |
| 67 | + <Authentication none="true" password="false" weak="false" strong="false" certificate="false" /> |
| 68 | + <LDevice inst="lDevice2"> |
| 69 | + <LN0 lnClass="LLN0" inst="" lnType="LLN0" /> |
| 70 | + <LN lnClass="MMXU" inst="1" lnType="MMXU" /> |
| 71 | + </LDevice> |
| 72 | + <LDevice inst="lDevice1"> |
| 73 | + <LN0 lnClass="LLN0" inst="" lnType="LLN0" /> |
| 74 | + <LN lnClass="MMXU" inst="2" lnType="MMXU" /> |
| 75 | + <LN lnClass="MMXU" inst="1" lnType="MMXU" /> |
| 76 | + </LDevice> |
| 77 | + <Association iedName="IED3" ldInst="lDevice2" lnClass="MMXU" lnInst="1" /> |
| 78 | + <Association desc="" iedName="IED3" ldInst="lDevice2" lnClass="MMXU" lnInst="1" kind="predefined" associationId="someId" /> |
| 79 | + <Association iedName="IED3" ldInst="lDevice2" lnClass="LLN0" lnInst="" kind="pre-established" associationId="someId" /> |
| 80 | + <Association desc="" iedName="IED3" ldInst="lDevice2" lnClass="MMXU" lnInst="2" kind="predefined" associationId="someId" /> |
| 81 | + <Association desc="" iedName="IED3" ldInst="lDevice2" lnClass="MMXU" lnInst="2" kind="predefined" associationId="someId" /> |
| 82 | + </Server> |
| 83 | + <ServerAt apName="AP1" /> |
| 84 | + <GOOSESecurity name="goose3" serialNumber="3" xferNumber="somexfer3" > |
| 85 | + <Subject commonName="none" idHierarchy="someId" /> |
| 86 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 87 | + </GOOSESecurity> |
| 88 | + <GOOSESecurity name="goose1" serialNumber="1" xferNumber="somexfer1" > |
| 89 | + <Subject commonName="none" idHierarchy="someId" /> |
| 90 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 91 | + </GOOSESecurity> |
| 92 | + <GOOSESecurity name="goose2" serialNumber="2" xferNumber="somexfer2" > |
| 93 | + <Subject commonName="none" idHierarchy="someId" /> |
| 94 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 95 | + </GOOSESecurity> |
| 96 | + <GOOSESecurity serialNumber="13" xferNumber="somexfer2" > |
| 97 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 98 | + </GOOSESecurity> |
| 99 | + <GOOSESecurity serialNumber="14" xferNumber="somexfer2" > |
| 100 | + <Subject idHierarchy="someId" /> |
| 101 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 102 | + </GOOSESecurity> |
| 103 | + <SMVSecurity name="smv3" serialNumber="3" xferNumber="somexfer3" > |
| 104 | + <Subject commonName="none" idHierarchy="someId" /> |
| 105 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 106 | + </SMVSecurity> |
| 107 | + <SMVSecurity name="smv1" serialNumber="1" xferNumber="somexfer1" > |
| 108 | + <Subject commonName="none" idHierarchy="someId" /> |
| 109 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 110 | + </SMVSecurity> |
| 111 | + <SMVSecurity name="smv2" serialNumber="2" xferNumber="somexfer2" > |
| 112 | + <Subject commonName="none" idHierarchy="someId" /> |
| 113 | + <IssuerName commonName="none" idHierarchy="someId" /> |
| 114 | + </SMVSecurity> |
| 115 | + </AccessPoint> |
| 116 | + </IED> |
| 117 | + <IED name="IED3"> |
| 118 | + <AccessPoint name="AP1" router="true" clock="true" kdc="true"> |
| 119 | + <Server timeout="13"> |
| 120 | + <Authentication none="false" password="true" weak="true" strong="true" certificate="true" /> |
| 121 | + <LDevice inst="lDevice1"> |
| 122 | + <LN0 lnClass="LLN0" inst="" lnType="LLN02" /> |
| 123 | + <LN lnClass="MMXU" inst="2" lnType="MMXU" /> |
| 124 | + </LDevice> |
| 125 | + </Server> |
| 126 | + </AccessPoint> |
| 127 | + </IED> |
| 128 | + <IED name="IED4"> |
| 129 | + <AccessPoint name="AP1"> |
| 130 | + <Server timeout="13"> |
| 131 | + <LDevice inst="lDevice1"> |
| 132 | + <LN0 lnClass="LLN0" inst="" lnType="LLN02" /> |
| 133 | + <LN lnClass="MMXU" inst="2" lnType="MMXU" /> |
| 134 | + </LDevice> |
| 135 | + </Server> |
| 136 | + </AccessPoint> |
| 137 | + </IED> |
| 138 | + <IED name="IED5"> |
| 139 | + <AccessPoint name="AP1"> |
| 140 | + <LN lnClass="MMXU" inst="1" lnType="invalidType" /> |
| 141 | + </AccessPoint> |
| 142 | + </IED> |
| 143 | + <IED name="IED6"> |
| 144 | + <AccessPoint name="AP1"> |
| 145 | + <ServerAt /> |
| 146 | + </AccessPoint> |
| 147 | + </IED> |
| 148 | + <DataTypeTemplates> |
| 149 | + <LNodeType id="LLN0" desc="desc" lnClass="LLN0"> |
| 150 | + <DO name="Beh" type="BehENS"/> |
| 151 | + </LNodeType> |
| 152 | + <LNodeType id="MMXU" desc="desc" lnClass="MMXU"> |
| 153 | + <DO name="A" type="WYE"/> |
| 154 | + </LNodeType> |
| 155 | + <DOType cdc="ENS" id="BehENS" > |
| 156 | + <DA name="stVal" bType="Enum" type="BehModKind" fc="ST" > |
| 157 | + <Val>off</Val> |
| 158 | + </DA> |
| 159 | + </DOType> |
| 160 | + <DOType id="WYE" cdc="WYE"> |
| 161 | + <SDO name="phsA" type="CMV" /> |
| 162 | + </DOType> |
| 163 | + <DOType id="CMV" cdc="CMV" > |
| 164 | + <DA name="cVal" bType="Struct" fc="MX" type="Vector"/> |
| 165 | + </DOType> |
| 166 | + <DAType id="Vector" > |
| 167 | + <BDA name="mag" bType="Struct" type="AnalogueValue" /> |
| 168 | + </DAType> |
| 169 | + <DAType id="AnalogueValue" > |
| 170 | + <BDA name="f" bType="FLOAT32" > |
| 171 | + <Val sGroup="3">60.60</Val> |
| 172 | + <Val sGroup="1">10.10</Val> |
| 173 | + <Val sGroup="2">40.10</Val> |
| 174 | + </BDA> |
| 175 | + </DAType> |
| 176 | + <EnumType id="BehModKind" > |
| 177 | + <EnumVal ord="1">on</EnumVal> |
| 178 | + <EnumVal ord="3">test</EnumVal> |
| 179 | + <EnumVal ord="5">off</EnumVal> |
| 180 | + </EnumType> |
| 181 | + </DataTypeTemplates> |
| 182 | + </SCL>`, |
| 183 | + "application/xml" |
| 184 | +); |
| 185 | + |
| 186 | +const baseAP = scl.querySelector('IED[name="IED1"]>AccessPoint')!; |
| 187 | +const equalAP = scl.querySelector('IED[name="IED2"]>AccessPoint')!; |
| 188 | +const diffAP = scl.querySelector('IED[name="IED3"]>AccessPoint')!; |
| 189 | +const invalidAP1 = scl.querySelector('IED[name="IED4"]>AccessPoint')!; |
| 190 | +const invalidAP2 = scl.querySelector('IED[name="IED5"]>AccessPoint')!; |
| 191 | +const invalidAP3 = scl.querySelector('IED[name="IED6"]>AccessPoint')!; |
| 192 | + |
| 193 | +describe("Description for SCL schema type AccessPoint", () => { |
| 194 | + it("returns undefined with invalid Server", () => |
| 195 | + expect(AccessPoint(invalidAP1)).to.be.undefined); |
| 196 | + |
| 197 | + it("return undefined with invalid LN", () => |
| 198 | + expect(AccessPoint(invalidAP2)).to.be.undefined); |
| 199 | + |
| 200 | + it("return undefined with invalid ServerAt", () => |
| 201 | + expect(AccessPoint(invalidAP3)).to.be.undefined); |
| 202 | + |
| 203 | + it("return router attribute defaulting to false", () => |
| 204 | + expect(AccessPoint(baseAP)?.router).to.be.false); |
| 205 | + |
| 206 | + it("return clock attribute defaulting to false", () => |
| 207 | + expect(AccessPoint(baseAP)?.clock).to.be.false); |
| 208 | + |
| 209 | + it("return kdc attribute defaulting to false", () => |
| 210 | + expect(AccessPoint(baseAP)?.kdc).to.be.false); |
| 211 | + |
| 212 | + it("returns same description with semantically equal LDevice's", () => |
| 213 | + expect(JSON.stringify(AccessPoint(baseAP))).to.equal( |
| 214 | + JSON.stringify(AccessPoint(equalAP)) |
| 215 | + )); |
| 216 | + |
| 217 | + it("returns different description with unequal LDevice elements", () => |
| 218 | + expect(JSON.stringify(AccessPoint(baseAP))).to.not.equal( |
| 219 | + JSON.stringify(AccessPoint(diffAP)) |
| 220 | + )); |
| 221 | +}); |
0 commit comments