| 1 | import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor"; |
| 2 | import { DnsRecordType } from "src/utils/datatypes/globalDataTypes"; |
| 3 | import { checkEntry, entryExists, searchForEntry } from "../common/data_tables"; |
| 4 | import { navigateTo } from "../common/navigation"; |
| 5 | import { loginAsAdmin, logout } from "../common/authentication"; |
| 6 | import { clearAndAddAdjustedNumberValue } from "./dnszones_settings"; |
| 7 | import { createDnsZone, parseZoneName } from "./dnszones"; |
| 8 | |
| 9 | const checkNewDnsRecord = ( |
| 10 | dnsRecordName: string, |
| 11 | type: DnsRecordType | string, |
| 12 | data: string |
| 13 | ) => { |
| 14 | searchForEntry(dnsRecordName); |
| 15 | cy.dataCy("table-row-" + dnsRecordName.toLowerCase() + "-idnsname").should( |
| 16 | "have.text", |
| 17 | dnsRecordName |
| 18 | ); |
| 19 | if (type !== "DS, NS" && type !== "NS, DS") { |
| 20 | cy.dataCy( |
| 21 | "table-row-" + dnsRecordName.toLowerCase() + "-dnsrecord_types" |
| 22 | ).should("have.text", type); |
| 23 | cy.dataCy( |
| 24 | "table-row-" + dnsRecordName.toLowerCase() + "-dnsrecord_data" |
| 25 | ).should("have.text", data); |
| 26 | } |
| 27 | }; |
| 28 | |
| 29 | const addAndCheckRecord = () => { |
| 30 | cy.dataCy("add-dns-records-modal-add-button").click(); |
| 31 | cy.dataCy("add-dns-records-modal").should("not.exist"); |
| 32 | cy.dataCy("add-dnsrecord-success").should("be.visible"); |
| 33 | }; |
| 34 | |
| 35 | const addDnsRecordTypeA = (ipAddress: string, createReverse: boolean) => { |
| 36 | cy.dataCy("modal-text-input-a-part-ip-address").type(ipAddress); |
| 37 | cy.dataCy("modal-text-input-a-part-ip-address").should( |
| 38 | "have.value", |
| 39 | ipAddress |
| 40 | ); |
| 41 | |
| 42 | if (createReverse) { |
| 43 | cy.dataCy("modal-checkbox-a-extra-create-reverse").click(); |
| 44 | cy.dataCy("modal-checkbox-a-extra-create-reverse").should("be.checked"); |
| 45 | } |
| 46 | |
| 47 | cy.dataCy("add-dns-records-modal-add-button").click(); |
| 48 | cy.dataCy("add-dns-zone-modal").should("not.exist"); |
| 49 | cy.dataCy("add-dnsrecord-success").should("be.visible"); |
| 50 | }; |
| 51 | |
| 52 | const addDnsRecordTypeAAAA = (ipAddress: string, createReverse: boolean) => { |
| 53 | cy.dataCy("modal-text-input-aaaa-part-ip-address").type(ipAddress); |
| 54 | cy.dataCy("modal-text-input-aaaa-part-ip-address").should( |
| 55 | "have.value", |
| 56 | ipAddress |
| 57 | ); |
| 58 | |
| 59 | if (createReverse) { |
| 60 | cy.dataCy("modal-checkbox-aaaa-extra-create-reverse").click(); |
| 61 | cy.dataCy("modal-checkbox-aaaa-extra-create-reverse").should("be.checked"); |
| 62 | } |
| 63 | |
| 64 | cy.dataCy("add-dns-records-modal-add-button").click(); |
| 65 | cy.dataCy("add-dns-zone-modal").should("not.exist"); |
| 66 | cy.dataCy("add-dnsrecord-success").should("be.visible"); |
| 67 | }; |
| 68 | |
| 69 | const addDnsRecordTypeA6 = (recordData: string) => { |
| 70 | cy.dataCy("modal-textarea-a6-part-data").type(recordData); |
| 71 | cy.dataCy("modal-textarea-a6-part-data").should("have.value", recordData); |
| 72 | |
| 73 | addAndCheckRecord(); |
| 74 | }; |
| 75 | |
| 76 | const addDnsRecordTypeAFSDB = (subtype: string, hostname: string) => { |
| 77 | clearAndAddAdjustedNumberValue( |
| 78 | "modal-number-input-afsdb-part-subtype", |
| 79 | subtype |
| 80 | ); |
| 81 | cy.dataCy("modal-number-input-afsdb-part-subtype").should( |
| 82 | "have.value", |
| 83 | subtype |
| 84 | ); |
| 85 | cy.dataCy("modal-text-input-afsdb-part-hostname").type(hostname); |
| 86 | cy.dataCy("modal-text-input-afsdb-part-hostname").should( |
| 87 | "have.value", |
| 88 | hostname |
| 89 | ); |
| 90 | |
| 91 | addAndCheckRecord(); |
| 92 | }; |
| 93 | |
| 94 | const addDnsRecordTypeCNAME = (hostname: string) => { |
| 95 | cy.dataCy("modal-text-input-cname-part-hostname").type(hostname); |
| 96 | cy.dataCy("modal-text-input-cname-part-hostname").should( |
| 97 | "have.value", |
| 98 | hostname |
| 99 | ); |
| 100 | |
| 101 | addAndCheckRecord(); |
| 102 | }; |
| 103 | |
| 104 | const addDnsRecordTypeDNAME = (target: string) => { |
| 105 | cy.dataCy("modal-text-input-dname-part-target").type(target); |
| 106 | cy.dataCy("modal-text-input-dname-part-target").should("have.value", target); |
| 107 | |
| 108 | addAndCheckRecord(); |
| 109 | }; |
| 110 | |
| 111 | const addDnsRecordTypeDS = ( |
| 112 | keyTag: string, |
| 113 | algorithm: string, |
| 114 | digestType: string, |
| 115 | digest: string |
| 116 | ) => { |
| 117 | clearAndAddAdjustedNumberValue("modal-number-input-ds-part-key-tag", keyTag); |
| 118 | cy.dataCy("modal-number-input-ds-part-key-tag").should("have.value", keyTag); |
| 119 | |
| 120 | clearAndAddAdjustedNumberValue( |
| 121 | "modal-number-input-ds-part-algorithm", |
| 122 | algorithm |
| 123 | ); |
| 124 | cy.dataCy("modal-number-input-ds-part-algorithm").should( |
| 125 | "have.value", |
| 126 | algorithm |
| 127 | ); |
| 128 | |
| 129 | clearAndAddAdjustedNumberValue( |
| 130 | "modal-number-input-ds-part-digest-type", |
| 131 | digestType |
| 132 | ); |
| 133 | cy.dataCy("modal-number-input-ds-part-digest-type").should( |
| 134 | "have.value", |
| 135 | digestType |
| 136 | ); |
| 137 | |
| 138 | clearAndAddAdjustedNumberValue("modal-textarea-ds-part-digest", digest); |
| 139 | cy.dataCy("modal-textarea-ds-part-digest").should("have.value", digest); |
| 140 | |
| 141 | addAndCheckRecord(); |
| 142 | }; |
| 143 | |
| 144 | const addDnsRecordTypeDLV = ( |
| 145 | keyTag: string, |
| 146 | algorithm: string, |
| 147 | digestType: string, |
| 148 | digest: string |
| 149 | ) => { |
| 150 | clearAndAddAdjustedNumberValue("modal-number-input-dlv-part-key-tag", keyTag); |
| 151 | cy.dataCy("modal-number-input-dlv-part-key-tag").should("have.value", keyTag); |
| 152 | |
| 153 | clearAndAddAdjustedNumberValue( |
| 154 | "modal-number-input-dlv-part-algorithm", |
| 155 | algorithm |
| 156 | ); |
| 157 | cy.dataCy("modal-number-input-dlv-part-algorithm").should( |
| 158 | "have.value", |
| 159 | algorithm |
| 160 | ); |
| 161 | |
| 162 | clearAndAddAdjustedNumberValue( |
| 163 | "modal-number-input-dlv-part-digest-type", |
| 164 | digestType |
| 165 | ); |
| 166 | cy.dataCy("modal-number-input-dlv-part-algorithm").should( |
| 167 | "have.value", |
| 168 | algorithm |
| 169 | ); |
| 170 | |
| 171 | clearAndAddAdjustedNumberValue("modal-textarea-dlv-part-digest", digest); |
| 172 | cy.dataCy("modal-textarea-dlv-part-digest").should("have.value", digest); |
| 173 | |
| 174 | addAndCheckRecord(); |
| 175 | }; |
| 176 | |
| 177 | const addDnsRecordTypeKX = (preference: string, exchanger: string) => { |
| 178 | clearAndAddAdjustedNumberValue( |
| 179 | "modal-number-input-kx-part-preference", |
| 180 | preference |
| 181 | ); |
| 182 | cy.dataCy("modal-number-input-kx-part-preference").should( |
| 183 | "have.value", |
| 184 | preference |
| 185 | ); |
| 186 | cy.dataCy("modal-text-input-kx-part-exchanger").type(exchanger); |
| 187 | cy.dataCy("modal-text-input-kx-part-exchanger").should( |
| 188 | "have.value", |
| 189 | exchanger |
| 190 | ); |
| 191 | |
| 192 | addAndCheckRecord(); |
| 193 | }; |
| 194 | |
| 195 | const addDnsRecordTypeLOC = ( |
| 196 | latDeg: string, |
| 197 | latMin: string, |
| 198 | latSec: string, |
| 199 | latDir: string, |
| 200 | lonDeg: string, |
| 201 | lonMin: string, |
| 202 | lonSec: string, |
| 203 | lonDir: string, |
| 204 | altitude: string, |
| 205 | size: string, |
| 206 | horizontalPrecision: string, |
| 207 | verticalPrecision: string |
| 208 | ) => { |
| 209 | clearAndAddAdjustedNumberValue("modal-number-input-loc-part-lat-deg", latDeg); |
| 210 | cy.dataCy("modal-number-input-loc-part-lat-deg").should("have.value", latDeg); |
| 211 | |
| 212 | clearAndAddAdjustedNumberValue("modal-number-input-loc-part-lat-min", latMin); |
| 213 | cy.dataCy("modal-number-input-loc-part-lat-min").should("have.value", latMin); |
| 214 | |
| 215 | clearAndAddAdjustedNumberValue("modal-number-input-loc-part-lat-sec", latSec); |
| 216 | cy.dataCy("modal-number-input-loc-part-lat-sec").should("have.value", latSec); |
| 217 | |
| 218 | cy.dataCy("modal-radio-loc-part-lat-dir-radio-" + latDir).click(); |
| 219 | cy.dataCy("modal-radio-loc-part-lat-dir-radio-" + latDir).should( |
| 220 | "be.checked" |
| 221 | ); |
| 222 | |
| 223 | clearAndAddAdjustedNumberValue("modal-number-input-loc-part-lon-deg", lonDeg); |
| 224 | cy.dataCy("modal-number-input-loc-part-lon-deg").should("have.value", lonDeg); |
| 225 | |
| 226 | clearAndAddAdjustedNumberValue("modal-number-input-loc-part-lon-min", lonMin); |
| 227 | cy.dataCy("modal-number-input-loc-part-lon-min").should("have.value", lonMin); |
| 228 | |
| 229 | clearAndAddAdjustedNumberValue("modal-number-input-loc-part-lon-sec", lonSec); |
| 230 | cy.dataCy("modal-number-input-loc-part-lon-sec").should("have.value", lonSec); |
| 231 | |
| 232 | cy.dataCy("modal-radio-loc-part-lon-dir-radio-" + lonDir).click(); |
| 233 | cy.dataCy("modal-radio-loc-part-lon-dir-radio-" + lonDir).should( |
| 234 | "be.checked" |
| 235 | ); |
| 236 | |
| 237 | clearAndAddAdjustedNumberValue( |
| 238 | "modal-number-input-loc-part-altitude", |
| 239 | altitude |
| 240 | ); |
| 241 | cy.dataCy("modal-number-input-loc-part-altitude").should( |
| 242 | "have.value", |
| 243 | altitude |
| 244 | ); |
| 245 | |
| 246 | clearAndAddAdjustedNumberValue("modal-number-input-loc-part-size", size); |
| 247 | cy.dataCy("modal-number-input-loc-part-size").should("have.value", size); |
| 248 | |
| 249 | clearAndAddAdjustedNumberValue( |
| 250 | "modal-number-input-loc-part-h-precision", |
| 251 | horizontalPrecision |
| 252 | ); |
| 253 | cy.dataCy("modal-number-input-loc-part-h-precision").should( |
| 254 | "have.value", |
| 255 | horizontalPrecision |
| 256 | ); |
| 257 | |
| 258 | clearAndAddAdjustedNumberValue( |
| 259 | "modal-number-input-loc-part-v-precision", |
| 260 | verticalPrecision |
| 261 | ); |
| 262 | cy.dataCy("modal-number-input-loc-part-v-precision").should( |
| 263 | "have.value", |
| 264 | verticalPrecision |
| 265 | ); |
| 266 | |
| 267 | addAndCheckRecord(); |
| 268 | }; |
| 269 | |
| 270 | const addDnsRecordTypeMX = (preference: string, exchanger: string) => { |
| 271 | clearAndAddAdjustedNumberValue( |
| 272 | "modal-number-input-mx-part-preference", |
| 273 | preference |
| 274 | ); |
| 275 | cy.dataCy("modal-text-input-mx-part-exchanger").type(exchanger); |
| 276 | cy.dataCy("modal-text-input-mx-part-exchanger").should( |
| 277 | "have.value", |
| 278 | exchanger |
| 279 | ); |
| 280 | |
| 281 | addAndCheckRecord(); |
| 282 | }; |
| 283 | |
| 284 | const addDnsRecordTypeNAPTR = ( |
| 285 | order: string, |
| 286 | preference: string, |
| 287 | flags: string, |
| 288 | service: string, |
| 289 | regexp: string, |
| 290 | replacement: string |
| 291 | ) => { |
| 292 | clearAndAddAdjustedNumberValue("modal-number-input-naptr-part-order", order); |
| 293 | cy.dataCy("modal-number-input-naptr-part-order").should("have.value", order); |
| 294 | |
| 295 | clearAndAddAdjustedNumberValue( |
| 296 | "modal-number-input-naptr-part-preference", |
| 297 | preference |
| 298 | ); |
| 299 | cy.dataCy("modal-number-input-naptr-part-preference").should( |
| 300 | "have.value", |
| 301 | preference |
| 302 | ); |
| 303 | |
| 304 | cy.dataCy("modal-select-naptr-part-flags").click(); |
| 305 | cy.dataCy("modal-select-naptr-part-flags").should( |
| 306 | "have.attr", |
| 307 | "aria-expanded", |
| 308 | "true" |
| 309 | ); |
| 310 | |
| 311 | cy.dataCy("modal-select-naptr-part-flags-option-" + flags) |
| 312 | .first() |
| 313 | .click(); |
| 314 | cy.dataCy("modal-select-naptr-part-flags").contains(flags); |
| 315 | |
| 316 | cy.dataCy("modal-text-input-naptr-part-service").type(service); |
| 317 | cy.dataCy("modal-text-input-naptr-part-service").should( |
| 318 | "have.value", |
| 319 | service |
| 320 | ); |
| 321 | |
| 322 | cy.dataCy("modal-text-input-naptr-part-regexp").type(regexp); |
| 323 | cy.dataCy("modal-text-input-naptr-part-regexp").should("have.value", regexp); |
| 324 | |
| 325 | cy.dataCy("modal-text-input-naptr-part-replacement").type(replacement); |
| 326 | cy.dataCy("modal-text-input-naptr-part-replacement").should( |
| 327 | "have.value", |
| 328 | replacement |
| 329 | ); |
| 330 | |
| 331 | addAndCheckRecord(); |
| 332 | }; |
| 333 | |
| 334 | const addDnsRecordTypeNS = (hostname: string, skipDnsCheck: boolean) => { |
| 335 | cy.dataCy("modal-text-input-ns-part-hostname").type(hostname); |
| 336 | cy.dataCy("modal-text-input-ns-part-hostname").should("have.value", hostname); |
| 337 | |
| 338 | if (skipDnsCheck) { |
| 339 | cy.dataCy("modal-checkbox-ns-part-skip-dns-check").click(); |
| 340 | cy.dataCy("modal-checkbox-ns-part-skip-dns-check").should("be.checked"); |
| 341 | } |
| 342 | |
| 343 | addAndCheckRecord(); |
| 344 | }; |
| 345 | |
| 346 | const addDnsRecordTypePTR = (hostname: string) => { |
| 347 | cy.dataCy("modal-text-input-ptr-part-hostname").type(hostname); |
| 348 | cy.dataCy("modal-text-input-ptr-part-hostname").should( |
| 349 | "have.value", |
| 350 | hostname |
| 351 | ); |
| 352 | |
| 353 | addAndCheckRecord(); |
| 354 | }; |
| 355 | |
| 356 | const addDnsRecordTypeSRV = ( |
| 357 | priority: string, |
| 358 | weight: string, |
| 359 | port: string, |
| 360 | target: string |
| 361 | ) => { |
| 362 | clearAndAddAdjustedNumberValue( |
| 363 | "modal-number-input-srv-part-priority", |
| 364 | priority |
| 365 | ); |
| 366 | cy.dataCy("modal-number-input-srv-part-priority").should( |
| 367 | "have.value", |
| 368 | priority |
| 369 | ); |
| 370 | |
| 371 | clearAndAddAdjustedNumberValue("modal-number-input-srv-part-weight", weight); |
| 372 | cy.dataCy("modal-number-input-srv-part-weight").should("have.value", weight); |
| 373 | |
| 374 | clearAndAddAdjustedNumberValue("modal-number-input-srv-part-port", port); |
| 375 | cy.dataCy("modal-number-input-srv-part-port").should("have.value", port); |
| 376 | |
| 377 | clearAndAddAdjustedNumberValue("modal-text-input-srv-part-target", target); |
| 378 | cy.dataCy("modal-text-input-srv-part-target").should("have.value", target); |
| 379 | |
| 380 | addAndCheckRecord(); |
| 381 | }; |
| 382 | |
| 383 | const addDnsRecordTypeSSHFP = ( |
| 384 | algorithm: string, |
| 385 | fpType: string, |
| 386 | fingerprint: string |
| 387 | ) => { |
| 388 | clearAndAddAdjustedNumberValue( |
| 389 | "modal-number-input-sshfp-part-algorithm", |
| 390 | algorithm |
| 391 | ); |
| 392 | cy.dataCy("modal-number-input-sshfp-part-algorithm").should( |
| 393 | "have.value", |
| 394 | algorithm |
| 395 | ); |
| 396 | |
| 397 | clearAndAddAdjustedNumberValue( |
| 398 | "modal-number-input-sshfp-part-fp-type", |
| 399 | fpType |
| 400 | ); |
| 401 | cy.dataCy("modal-number-input-sshfp-part-fp-type").should( |
| 402 | "have.value", |
| 403 | fpType |
| 404 | ); |
| 405 | |
| 406 | cy.dataCy("modal-textarea-sshfp-part-fingerprint").type(fingerprint); |
| 407 | cy.dataCy("modal-textarea-sshfp-part-fingerprint").should( |
| 408 | "have.value", |
| 409 | fingerprint |
| 410 | ); |
| 411 | |
| 412 | cy.dataCy("add-dns-records-modal-add-button").click(); |
| 413 | cy.dataCy("add-dnsrecord-success").should("be.visible"); |
| 414 | cy.dataCy("add-dns-records-modal").should("not.exist"); |
| 415 | }; |
| 416 | |
| 417 | const addDnsRecordTypeTLSA = ( |
| 418 | certUsage: string, |
| 419 | selector: string, |
| 420 | matchingType: string, |
| 421 | certAssociationData: string |
| 422 | ) => { |
| 423 | clearAndAddAdjustedNumberValue( |
| 424 | "modal-number-input-tlsa-part-cert-usage", |
| 425 | certUsage |
| 426 | ); |
| 427 | cy.dataCy("modal-number-input-tlsa-part-cert-usage").should( |
| 428 | "have.value", |
| 429 | certUsage |
| 430 | ); |
| 431 | |
| 432 | clearAndAddAdjustedNumberValue( |
| 433 | "modal-number-input-tlsa-part-selector", |
| 434 | selector |
| 435 | ); |
| 436 | cy.dataCy("modal-number-input-tlsa-part-selector").should( |
| 437 | "have.value", |
| 438 | selector |
| 439 | ); |
| 440 | |
| 441 | clearAndAddAdjustedNumberValue( |
| 442 | "modal-number-input-tlsa-part-matching-type", |
| 443 | matchingType |
| 444 | ); |
| 445 | cy.dataCy("modal-number-input-tlsa-part-matching-type").should( |
| 446 | "have.value", |
| 447 | matchingType |
| 448 | ); |
| 449 | |
| 450 | cy.dataCy("modal-textarea-tlsa-part-cert-association-data").type( |
| 451 | certAssociationData |
| 452 | ); |
| 453 | cy.dataCy("modal-textarea-tlsa-part-cert-association-data").should( |
| 454 | "have.value", |
| 455 | certAssociationData |
| 456 | ); |
| 457 | |
| 458 | cy.dataCy("add-dns-records-modal-add-button").click(); |
| 459 | cy.dataCy("add-dnsrecord-success").should("be.visible"); |
| 460 | cy.dataCy("add-dns-records-modal").should("not.exist"); |
| 461 | }; |
| 462 | |
| 463 | const addDnsRecordTypeTXT = (data: string) => { |
| 464 | cy.dataCy("modal-textarea-txt-part-data").type(data); |
| 465 | cy.dataCy("modal-textarea-txt-part-data").should("have.value", data); |
| 466 | |
| 467 | cy.dataCy("add-dns-records-modal-add-button").click(); |
| 468 | cy.dataCy("add-dnsrecord-success").should("be.visible"); |
| 469 | cy.dataCy("add-dns-records-modal").should("not.exist"); |
| 470 | }; |
| 471 | |
| 472 | const addDnsRecordTypeURI = ( |
| 473 | priority: string, |
| 474 | weight: string, |
| 475 | target: string |
| 476 | ) => { |
| 477 | clearAndAddAdjustedNumberValue( |
| 478 | "modal-number-input-uri-part-priority", |
| 479 | priority |
| 480 | ); |
| 481 | cy.dataCy("modal-number-input-uri-part-priority").should( |
| 482 | "have.value", |
| 483 | priority |
| 484 | ); |
| 485 | |
| 486 | clearAndAddAdjustedNumberValue("modal-number-input-uri-part-weight", weight); |
| 487 | cy.dataCy("modal-number-input-uri-part-weight").should("have.value", weight); |
| 488 | |
| 489 | clearAndAddAdjustedNumberValue("modal-text-input-uri-part-target", target); |
| 490 | cy.dataCy("modal-text-input-uri-part-target").should("have.value", target); |
| 491 | |
| 492 | cy.dataCy("add-dns-records-modal-add-button").click(); |
| 493 | cy.dataCy("add-dnsrecord-success").should("be.visible"); |
| 494 | cy.dataCy("add-dns-records-modal").should("not.exist"); |
| 495 | }; |
| 496 | |
| 497 | const createDnsRecord = (dnsRecordName: string, type: DnsRecordType) => { |
| 498 | cy.dataCy("add-dns-records").click(); |
| 499 | cy.dataCy("add-dns-records-modal").should("be.visible"); |
| 500 | |
| 501 | cy.dataCy("record-name").type(dnsRecordName); |
| 502 | cy.dataCy("record-name").should("have.value", dnsRecordName); |
| 503 | |
| 504 | cy.dataCy("record-type-toggle").click(); |
| 505 | cy.dataCy("record-type-toggle").should("have.attr", "aria-expanded", "true"); |
| 506 | cy.dataCy("record-type-option") |
| 507 | .find("span") |
| 508 | .contains(new RegExp(`^${type}$`)) |
| 509 | .click(); |
| 510 | cy.dataCy("record-type-toggle").find("span").should("have.text", type); |
| 511 | |
| 512 | switch (type) { |
| 513 | case "A": |
| 514 | addDnsRecordTypeA("192.168.66.67", false); |
| 515 | checkNewDnsRecord(dnsRecordName, "A", "192.168.66.67"); |
| 516 | break; |
| 517 | case "AAAA": |
| 518 | addDnsRecordTypeAAAA("2001:db8::1", false); |
| 519 | checkNewDnsRecord(dnsRecordName, "AAAA", "2001:db8::1"); |
| 520 | break; |
| 521 | case "A6": |
| 522 | addDnsRecordTypeA6("record data"); |
| 523 | checkNewDnsRecord(dnsRecordName, "A6", "record data"); |
| 524 | break; |
| 525 | case "AFSDB": |
| 526 | addDnsRecordTypeAFSDB("1", "hostname"); |
| 527 | checkNewDnsRecord(dnsRecordName, "AFSDB", "1 hostname"); |
| 528 | break; |
| 529 | case "CNAME": |
| 530 | addDnsRecordTypeCNAME("hostname.example.com"); |
| 531 | checkNewDnsRecord(dnsRecordName, "CNAME", "hostname.example.com"); |
| 532 | break; |
| 533 | case "DNAME": |
| 534 | addDnsRecordTypeDNAME("target.example.com"); |
| 535 | checkNewDnsRecord(dnsRecordName, "DNAME", "target.example.com"); |
| 536 | break; |
| 537 | case "DS": |
| 538 | addDnsRecordTypeDS( |
| 539 | "20326", |
| 540 | "8", |
| 541 | "2", |
| 542 | "E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F53853" |
| 543 | ); |
| 544 | // This is expected to be created alongside a NS record, so both must be present when checking data |
| 545 | checkNewDnsRecord( |
| 546 | dnsRecordName, |
| 547 | "DS, NS", |
| 548 | "20326 8 2 E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F53853, server.ipa.demo" |
| 549 | ); |
| 550 | break; |
| 551 | case "DLV": |
| 552 | addDnsRecordTypeDLV( |
| 553 | "34505", |
| 554 | "8", |
| 555 | "2", |
| 556 | "A3746E9665885C21431E75193239C6A481B23E3905553655CE9C2DD4C02F2393" |
| 557 | ); |
| 558 | checkNewDnsRecord( |
| 559 | dnsRecordName, |
| 560 | "DLV", |
| 561 | "34505 8 2 A3746E9665885C21431E75193239C6A481B23E3905553655CE9C2DD4C02F2393" |
| 562 | ); |
| 563 | break; |
| 564 | case "KX": |
| 565 | addDnsRecordTypeKX("10", "exchanger.example.com"); |
| 566 | checkNewDnsRecord(dnsRecordName, "KX", "10 exchanger.example.com"); |
| 567 | break; |
| 568 | case "LOC": |
| 569 | addDnsRecordTypeLOC( |
| 570 | "40", |
| 571 | "0", |
| 572 | "0", |
| 573 | "N", |
| 574 | "74", |
| 575 | "0", |
| 576 | "0", |
| 577 | "W", |
| 578 | "0", |
| 579 | "100", |
| 580 | "10", |
| 581 | "10" |
| 582 | ); |
| 583 | checkNewDnsRecord(dnsRecordName, "LOC", "40 0 0 N 74 0 0 W 0 100 10 10"); |
| 584 | break; |
| 585 | case "MX": |
| 586 | addDnsRecordTypeMX("10", "mail.example.com"); |
| 587 | checkNewDnsRecord(dnsRecordName, "MX", "10 mail.example.com"); |
| 588 | break; |
| 589 | case "NAPTR": |
| 590 | addDnsRecordTypeNAPTR("100", "10", "U", "sip", ".*", "sip.example.com"); |
| 591 | checkNewDnsRecord( |
| 592 | dnsRecordName, |
| 593 | "NAPTR", |
| 594 | "100 10 U sip .* sip.example.com" |
| 595 | ); |
| 596 | break; |
| 597 | case "NS": |
| 598 | addDnsRecordTypeNS("server.ipa.demo", true); |
| 599 | checkNewDnsRecord(dnsRecordName, "NS", "server.ipa.demo"); |
| 600 | break; |
| 601 | case "PTR": |
| 602 | addDnsRecordTypePTR("hostname.example.com"); |
| 603 | checkNewDnsRecord(dnsRecordName, "PTR", "hostname.example.com"); |
| 604 | break; |
| 605 | case "SRV": |
| 606 | addDnsRecordTypeSRV("10", "5", "8080", "target.example.com"); |
| 607 | checkNewDnsRecord(dnsRecordName, "SRV", "10 5 8080 target.example.com"); |
| 608 | break; |
| 609 | case "SSHFP": |
| 610 | addDnsRecordTypeSSHFP( |
| 611 | "1", |
| 612 | "1", |
| 613 | "d4b01d51ebe9c82a2e8b92425a8c9fc2b818f2e3" |
| 614 | ); |
| 615 | checkNewDnsRecord( |
| 616 | dnsRecordName, |
| 617 | "SSHFP", |
| 618 | "1 1 d4b01d51ebe9c82a2e8b92425a8c9fc2b818f2e3" |
| 619 | ); |
| 620 | break; |
| 621 | case "TLSA": |
| 622 | addDnsRecordTypeTLSA("1", "1", "1", "data"); |
| 623 | checkNewDnsRecord(dnsRecordName, "TLSA", "1 1 1 data"); |
| 624 | break; |
| 625 | case "TXT": |
| 626 | addDnsRecordTypeTXT("text record data"); |
| 627 | checkNewDnsRecord(dnsRecordName, "TXT", "text record data"); |
| 628 | break; |
| 629 | case "URI": |
| 630 | addDnsRecordTypeURI("10", "5", "https://example.com"); |
| 631 | checkNewDnsRecord(dnsRecordName, "URI", '10 5 "https://example.com"'); |
| 632 | break; |
| 633 | } |
| 634 | }; |
| 635 | |
| 636 | When( |
| 637 | "I create a DNS record {DnsRecordType} with name {string}", |
| 638 | (recordType: DnsRecordType, recordName: string) => { |
| 639 | createDnsRecord(recordName, recordType); |
| 640 | } |
| 641 | ); |
| 642 | |
| 643 | When("I delete DNS record {string}", (recordName: string) => { |
| 644 | checkEntry(recordName); |
| 645 | cy.dataCy("delete-dns-records").click(); |
| 646 | cy.dataCy("modal-delete-dns-records").should("be.visible"); |
| 647 | cy.dataCy("modal-button-delete").click(); |
| 648 | cy.dataCy("modal-delete-dns-records").should("not.exist"); |
| 649 | cy.dataCy("remove-dnsrecords-success").should("be.visible"); |
| 650 | }); |
| 651 | |
| 652 | Then( |
| 653 | "I should see DNS record {string} with type {string} and data {string}", |
| 654 | (recordName: string, recordType: DnsRecordType, recordData: string) => { |
| 655 | checkNewDnsRecord(recordName, recordType, recordData); |
| 656 | } |
| 657 | ); |
| 658 | |
| 659 | Then("I should not see DNS record {string}", (recordName: string) => { |
| 660 | cy.dataCy("dns-zones-dns-records-table").should("not.contain", recordName); |
| 661 | }); |
| 662 | |
| 663 | Given( |
| 664 | "DNS zone {string} exists and has record {string} with name {string} and data {string}", |
| 665 | ( |
| 666 | dnsZoneName: string, |
| 667 | recordType: DnsRecordType, |
| 668 | recordName: string, |
| 669 | recordData: string |
| 670 | ) => { |
| 671 | loginAsAdmin(); |
| 672 | navigateTo("dns-zones"); |
| 673 | |
| 674 | createDnsZone(dnsZoneName); |
| 675 | searchForEntry(parseZoneName(dnsZoneName)); |
| 676 | entryExists(parseZoneName(dnsZoneName)); |
| 677 | |
| 678 | navigateTo("dns-zones/" + dnsZoneName + "./dns-records"); |
| 679 | createDnsRecord(recordName, recordType); |
| 680 | checkNewDnsRecord(recordName, recordType, recordData); |
| 681 | logout(); |
| 682 | } |
| 683 | ); |