|
| 1 | +describe("Comparator", () => { |
| 2 | + it("should render error when organization or repository does not exist", () => { |
| 3 | + cy.intercept( |
| 4 | + "GET", |
| 5 | + "https://api.securityscorecards.dev/projects/github.com/nodejs/node/?commit=2ac5e9889aba461f5a54d320973d2574980d206b", |
| 6 | + { |
| 7 | + statusCode: 404, |
| 8 | + } |
| 9 | + ).as("getDataPreviousCommit"); |
| 10 | + |
| 11 | + cy.intercept( |
| 12 | + "GET", |
| 13 | + "https://api.securityscorecards.dev/projects/github.com/nodejs/node/?commit=077fd7d83d7d41695137c1af5b9be1d72250e69e", |
| 14 | + { |
| 15 | + statusCode: 404, |
| 16 | + } |
| 17 | + ).as("getDataCurrentCommit"); |
| 18 | + |
| 19 | + cy.visit( |
| 20 | + "localhost:3000/openssf-scorecard-api-visualizer/#/projects/github.com/nodejs/node/compare/2ac5e9889aba461f5a54d320973d2574980d206b/077fd7d83d7d41695137c1af5b9be1d72250e69e" |
| 21 | + ); |
| 22 | + cy.wait("@getDataPreviousCommit"); // first try as react query behaves |
| 23 | + cy.wait("@getDataPreviousCommit"); // second try |
| 24 | + cy.wait("@getDataPreviousCommit"); // third try |
| 25 | + cy.wait("@getDataCurrentCommit"); // first try as react query behaves |
| 26 | + cy.wait("@getDataCurrentCommit"); // second try |
| 27 | + cy.wait("@getDataCurrentCommit"); // third try |
| 28 | + cy.get("h1", { timeout: 10000 }).should( |
| 29 | + "contain", |
| 30 | + "An error ocurred. Please refresh/try again." |
| 31 | + ); |
| 32 | + cy.get("p", { timeout: 10000 }).should( |
| 33 | + "contain", |
| 34 | + "Please check if the org/repository/commit has been analysed by the Scorecard." |
| 35 | + ); |
| 36 | + }); |
| 37 | + it("should render error when the previous commit hash does not exist", () => { |
| 38 | + cy.intercept( |
| 39 | + "GET", |
| 40 | + "https://api.securityscorecards.dev/projects/github.com/nodejs/node/?commit=2ac5e9889aba461f5a54d320973d2574980d206b", |
| 41 | + { |
| 42 | + statusCode: 404, |
| 43 | + } |
| 44 | + ).as("getDataPreviousCommit"); |
| 45 | + |
| 46 | + cy.intercept( |
| 47 | + "GET", |
| 48 | + "https://api.securityscorecards.dev/projects/github.com/nodejs/node/?commit=077fd7d83d7d41695137c1af5b9be1d72250e69e", |
| 49 | + { |
| 50 | + statusCode: 200, |
| 51 | + fixture: "077fd7d83d7d41695137c1af5b9be1d72250e69e.json", |
| 52 | + } |
| 53 | + ).as("getDataCurrentCommit"); |
| 54 | + |
| 55 | + cy.visit( |
| 56 | + "localhost:3000/openssf-scorecard-api-visualizer/#/projects/github.com/nodejs/node/compare/2ac5e9889aba461f5a54d320973d2574980d206b/077fd7d83d7d41695137c1af5b9be1d72250e69e" |
| 57 | + ); |
| 58 | + cy.wait("@getDataPreviousCommit"); // first try as react query behaves |
| 59 | + cy.wait("@getDataPreviousCommit"); // second try |
| 60 | + cy.wait("@getDataPreviousCommit"); // third try |
| 61 | + cy.wait("@getDataCurrentCommit"); // first try |
| 62 | + |
| 63 | + cy.get("h1", { timeout: 10000 }).should( |
| 64 | + "contain", |
| 65 | + "An error ocurred. Please refresh/try again." |
| 66 | + ); |
| 67 | + cy.get("p", { timeout: 10000 }).should( |
| 68 | + "contain", |
| 69 | + "Please check if the org/repository/commit has been analysed by the Scorecard." |
| 70 | + ); |
| 71 | + }); |
| 72 | + it("should render error when the current commit hash does not exist", () => { |
| 73 | + cy.intercept( |
| 74 | + "GET", |
| 75 | + "https://api.securityscorecards.dev/projects/github.com/nodejs/node/?commit=2ac5e9889aba461f5a54d320973d2574980d206b", |
| 76 | + { |
| 77 | + statusCode: 200, |
| 78 | + fixture: "2ac5e9889aba461f5a54d320973d2574980d206b.json", |
| 79 | + } |
| 80 | + ).as("getDataPreviousCommit"); |
| 81 | + |
| 82 | + cy.intercept( |
| 83 | + "GET", |
| 84 | + "https://api.securityscorecards.dev/projects/github.com/nodejs/node/?commit=077fd7d83d7d41695137c1af5b9be1d72250e69e", |
| 85 | + { |
| 86 | + statusCode: 404, |
| 87 | + } |
| 88 | + ).as("getDataCurrentCommit"); |
| 89 | + |
| 90 | + cy.visit( |
| 91 | + "localhost:3000/openssf-scorecard-api-visualizer/#/projects/github.com/nodejs/node/compare/2ac5e9889aba461f5a54d320973d2574980d206b/077fd7d83d7d41695137c1af5b9be1d72250e69e" |
| 92 | + ); |
| 93 | + cy.wait("@getDataPreviousCommit"); // first try as react query behaves |
| 94 | + cy.wait("@getDataCurrentCommit"); // first try as react query behaves |
| 95 | + cy.wait("@getDataCurrentCommit"); // second try |
| 96 | + cy.wait("@getDataCurrentCommit"); // third try |
| 97 | + |
| 98 | + cy.get("h1", { timeout: 10000 }).should( |
| 99 | + "contain", |
| 100 | + "An error ocurred. Please refresh/try again." |
| 101 | + ); |
| 102 | + cy.get("p", { timeout: 10000 }).should( |
| 103 | + "contain", |
| 104 | + "Please check if the org/repository/commit has been analysed by the Scorecard." |
| 105 | + ); |
| 106 | + }); |
| 107 | + it("should compare data from each commit as expected", () => { |
| 108 | + cy.intercept( |
| 109 | + "GET", |
| 110 | + "https://api.securityscorecards.dev/projects/github.com/nodejs/node/?commit=2ac5e9889aba461f5a54d320973d2574980d206b", |
| 111 | + { |
| 112 | + statusCode: 200, |
| 113 | + fixture: "2ac5e9889aba461f5a54d320973d2574980d206b.json", |
| 114 | + } |
| 115 | + ).as("getDataPreviousCommit"); |
| 116 | + |
| 117 | + cy.intercept( |
| 118 | + "GET", |
| 119 | + "https://api.securityscorecards.dev/projects/github.com/nodejs/node/?commit=077fd7d83d7d41695137c1af5b9be1d72250e69e", |
| 120 | + { |
| 121 | + statusCode: 200, |
| 122 | + fixture: "077fd7d83d7d41695137c1af5b9be1d72250e69e.json", |
| 123 | + } |
| 124 | + ).as("getDataCurrentCommit"); |
| 125 | + |
| 126 | + cy.visit( |
| 127 | + "localhost:3000/openssf-scorecard-api-visualizer/#/projects/github.com/nodejs/node/compare/2ac5e9889aba461f5a54d320973d2574980d206b/077fd7d83d7d41695137c1af5b9be1d72250e69e" |
| 128 | + ); |
| 129 | + cy.wait("@getDataPreviousCommit"); // first try as react query behaves |
| 130 | + cy.wait("@getDataCurrentCommit"); // first try as react query behaves |
| 131 | + |
| 132 | + cy.get("h1").should( |
| 133 | + "contain", |
| 134 | + "OpenSSF Scorecard comparator for nodejs/node" |
| 135 | + ); |
| 136 | + |
| 137 | + cy.get('[data-testid="current-score-and-badge"] > h2').should( |
| 138 | + "contain", |
| 139 | + "Score: 7.3/10" |
| 140 | + ); |
| 141 | + |
| 142 | + cy.get('[data-testid="current-score-and-badge"] > span') |
| 143 | + .should("contain", "Unchanged") |
| 144 | + .and("have.css", "background-color") |
| 145 | + .and("eq", "rgb(108, 117, 125)"); |
| 146 | + |
| 147 | + cy.get('[data-testid="commits-analysis"]').should( |
| 148 | + "contain", |
| 149 | + "Analysis of commits (077fd7d8) and (2ac5e988)" |
| 150 | + ); |
| 151 | + |
| 152 | + cy.get('[data-testid="commits-analysis"] > a:first-child') |
| 153 | + .should("contain", "(077fd7d8)") |
| 154 | + .and("have.attr", "href") |
| 155 | + .and( |
| 156 | + "include", |
| 157 | + "https://github.com/nodejs/node/commit/077fd7d83d7d41695137c1af5b9be1d72250e69e" |
| 158 | + ); |
| 159 | + |
| 160 | + cy.get('[data-testid="commits-analysis"] > a:last-child') |
| 161 | + .should("contain", "(2ac5e988)") |
| 162 | + .and("have.attr", "href") |
| 163 | + .and( |
| 164 | + "include", |
| 165 | + "https://github.com/nodejs/node/commit/2ac5e9889aba461f5a54d320973d2574980d206b" |
| 166 | + ); |
| 167 | + |
| 168 | + // @TODO: restore when https://github.com/KoolTheba/openssf-scorecard-api-visualizer/actions/runs/5457182231/jobs/9930918315?pr=106 is solved |
| 169 | + // cy.get('[data-testid="date"]').should("contain", "Date: June 8, 2023"); |
| 170 | + |
| 171 | + cy.get('[data-testid="scorecard-version"]').should( |
| 172 | + "contain", |
| 173 | + "Scorecard version v4.10.5 (27cfe92e)" |
| 174 | + ); |
| 175 | + |
| 176 | + cy.get('[data-testid="Binary-Artifacts"]').should( |
| 177 | + "contain", |
| 178 | + "Binary-Artifacts" |
| 179 | + ); |
| 180 | + cy.get('[data-testid="Binary-Artifacts"] > div > span') |
| 181 | + .should("contain", "Unchanged") |
| 182 | + .and("have.css", "background-color") |
| 183 | + .and("eq", "rgb(108, 117, 125)"); |
| 184 | + cy.get('[data-testid="Binary-Artifacts"] > span').should("contain", "0/10"); |
| 185 | + |
| 186 | + cy.get('[data-testid="Branch-Protection"]').should( |
| 187 | + "contain", |
| 188 | + "Branch-Protection" |
| 189 | + ); |
| 190 | + cy.get('[data-testid="Branch-Protection"] > div > span') |
| 191 | + .should("contain", "Unchanged") |
| 192 | + .and("have.css", "background-color") |
| 193 | + .and("eq", "rgb(108, 117, 125)"); |
| 194 | + cy.get('[data-testid="Branch-Protection"] > span').should( |
| 195 | + "contain", |
| 196 | + "-1/10" |
| 197 | + ); |
| 198 | + |
| 199 | + cy.get('[data-testid="CI-Tests"]').should("contain", "CI-Tests"); |
| 200 | + cy.get('[data-testid="CI-Tests"] > div > span') |
| 201 | + .should("contain", "Decreased -1") |
| 202 | + .and("have.css", "background-color") |
| 203 | + .and("eq", "rgb(220, 53, 69)"); |
| 204 | + cy.get('[data-testid="CI-Tests"] > span').and("contain", "9/10"); |
| 205 | + cy.get('[data-testid="CI-Tests"] ~ h4').should( |
| 206 | + "contain", |
| 207 | + "Additional details / variations" |
| 208 | + ); |
| 209 | + |
| 210 | + cy.get('[data-testid="CII-Best-Practices"]').should( |
| 211 | + "contain", |
| 212 | + "CII-Best-Practices" |
| 213 | + ); |
| 214 | + cy.get('[data-testid="CII-Best-Practices"] > div > span') |
| 215 | + .should("contain", "Unchanged") |
| 216 | + .and("have.css", "background-color") |
| 217 | + .and("eq", "rgb(108, 117, 125)"); |
| 218 | + cy.get('[data-testid="CII-Best-Practices"] > span').should( |
| 219 | + "contain", |
| 220 | + "5/10" |
| 221 | + ); |
| 222 | + |
| 223 | + cy.get('[data-testid="Code-Review"]').should("contain", "Code-Review"); |
| 224 | + cy.get('[data-testid="Code-Review"] > div > span') |
| 225 | + .should("contain", "Unchanged") |
| 226 | + .and("have.css", "background-color") |
| 227 | + .and("eq", "rgb(108, 117, 125)"); |
| 228 | + cy.get('[data-testid="Code-Review"] > span').should("contain", "0/10"); |
| 229 | + cy.get('[data-testid="Code-Review"] ~ h4').should( |
| 230 | + "contain", |
| 231 | + "Additional details / variations" |
| 232 | + ); |
| 233 | + |
| 234 | + cy.get('[data-testid="Contributors"]').should("contain", "Contributors"); |
| 235 | + cy.get('[data-testid="Contributors"] > div > span') |
| 236 | + .should("contain", "Unchanged") |
| 237 | + .and("have.css", "background-color") |
| 238 | + .and("eq", "rgb(108, 117, 125)"); |
| 239 | + cy.get('[data-testid="Contributors"] > span').should("contain", "10/10"); |
| 240 | + |
| 241 | + cy.get('[data-testid="Dangerous-Workflow"]').should( |
| 242 | + "contain", |
| 243 | + "Dangerous-Workflow" |
| 244 | + ); |
| 245 | + cy.get('[data-testid="Dangerous-Workflow"] > div > span') |
| 246 | + .should("contain", "Unchanged") |
| 247 | + .and("have.css", "background-color") |
| 248 | + .and("eq", "rgb(108, 117, 125)"); |
| 249 | + cy.get('[data-testid="Dangerous-Workflow"] > span').should( |
| 250 | + "contain", |
| 251 | + "10/10" |
| 252 | + ); |
| 253 | + |
| 254 | + cy.get('[data-testid="Dependency-Update-Tool"]').should( |
| 255 | + "contain", |
| 256 | + "Dependency-Update-Tool" |
| 257 | + ); |
| 258 | + cy.get('[data-testid="Dependency-Update-Tool"] > div > span') |
| 259 | + .should("contain", "Unchanged") |
| 260 | + .and("have.css", "background-color") |
| 261 | + .and("eq", "rgb(108, 117, 125)"); |
| 262 | + cy.get('[data-testid="Dependency-Update-Tool"] > span').should( |
| 263 | + "contain", |
| 264 | + "10/10" |
| 265 | + ); |
| 266 | + |
| 267 | + cy.get('[data-testid="Fuzzing"]').should("contain", "Fuzzing"); |
| 268 | + cy.get('[data-testid="Fuzzing"] > div > span') |
| 269 | + .should("contain", "Unchanged") |
| 270 | + .and("have.css", "background-color") |
| 271 | + .and("eq", "rgb(108, 117, 125)"); |
| 272 | + cy.get('[data-testid="Fuzzing"] > span').should("contain", "10/10"); |
| 273 | + |
| 274 | + cy.get('[data-testid="License"]').should("contain", "License"); |
| 275 | + cy.get('[data-testid="License"] > div > span') |
| 276 | + .should("contain", "Unchanged") |
| 277 | + .and("have.css", "background-color") |
| 278 | + .and("eq", "rgb(108, 117, 125)"); |
| 279 | + cy.get('[data-testid="License"] > span').should("contain", "9/10"); |
| 280 | + |
| 281 | + cy.get('[data-testid="Maintained"]').should("contain", "Maintained"); |
| 282 | + cy.get('[data-testid="Maintained"] > div > span') |
| 283 | + .should("contain", "Unchanged") |
| 284 | + .and("have.css", "background-color") |
| 285 | + .and("eq", "rgb(108, 117, 125)"); |
| 286 | + cy.get('[data-testid="Maintained"] > span').should("contain", "10/10"); |
| 287 | + cy.get('[data-testid="Maintained"] ~ h4').should( |
| 288 | + "contain", |
| 289 | + "Additional details / variations" |
| 290 | + ); |
| 291 | + |
| 292 | + cy.get('[data-testid="Packaging"]').should("contain", "Packaging"); |
| 293 | + cy.get('[data-testid="Packaging"] > div > span') |
| 294 | + .should("contain", "Unchanged") |
| 295 | + .and("have.css", "background-color") |
| 296 | + .and("eq", "rgb(108, 117, 125)"); |
| 297 | + cy.get('[data-testid="Packaging"] > span').should("contain", "-1/10"); |
| 298 | + |
| 299 | + cy.get('[data-testid="Pinned-Dependencies"]').should( |
| 300 | + "contain", |
| 301 | + "Pinned-Dependencies" |
| 302 | + ); |
| 303 | + cy.get('[data-testid="Pinned-Dependencies"] > div > span') |
| 304 | + .should("contain", "Unchanged") |
| 305 | + .and("have.css", "background-color") |
| 306 | + .and("eq", "rgb(108, 117, 125)"); |
| 307 | + cy.get('[data-testid="Pinned-Dependencies"] > span').should( |
| 308 | + "contain", |
| 309 | + "7/10" |
| 310 | + ); |
| 311 | + cy.get('[data-testid="Pinned-Dependencies"] ~ h4').should( |
| 312 | + "contain", |
| 313 | + "Additional details / variations" |
| 314 | + ); |
| 315 | + |
| 316 | + cy.get('[data-testid="SAST"]').should("contain", "SAST"); |
| 317 | + cy.get('[data-testid="SAST"] > div > span') |
| 318 | + .should("contain", "Unchanged") |
| 319 | + .and("have.css", "background-color") |
| 320 | + .and("eq", "rgb(108, 117, 125)"); |
| 321 | + cy.get('[data-testid="SAST"] > span').should("contain", "0/10"); |
| 322 | + |
| 323 | + cy.get('[data-testid="Security-Policy"]').should( |
| 324 | + "contain", |
| 325 | + "Security-Policy" |
| 326 | + ); |
| 327 | + cy.get('[data-testid="Security-Policy"] > div > span') |
| 328 | + .should("contain", "Unchanged") |
| 329 | + .and("have.css", "background-color") |
| 330 | + .and("eq", "rgb(108, 117, 125)"); |
| 331 | + cy.get('[data-testid="Security-Policy"] > span').should("contain", "10/10"); |
| 332 | + |
| 333 | + cy.get('[data-testid="Signed-Releases"]').should( |
| 334 | + "contain", |
| 335 | + "Signed-Releases" |
| 336 | + ); |
| 337 | + cy.get('[data-testid="Signed-Releases"] > div > span') |
| 338 | + .should("contain", "Unchanged") |
| 339 | + .and("have.css", "background-color") |
| 340 | + .and("eq", "rgb(108, 117, 125)"); |
| 341 | + cy.get('[data-testid="Signed-Releases"] > span').should("contain", "-1/10"); |
| 342 | + |
| 343 | + cy.get('[data-testid="Token-Permissions"]').should( |
| 344 | + "contain", |
| 345 | + "Token-Permissions" |
| 346 | + ); |
| 347 | + cy.get('[data-testid="Token-Permissions"] > div > span') |
| 348 | + .should("contain", "Unchanged") |
| 349 | + .and("have.css", "background-color") |
| 350 | + .and("eq", "rgb(108, 117, 125)"); |
| 351 | + cy.get('[data-testid="Token-Permissions"] > span').should( |
| 352 | + "contain", |
| 353 | + "10/10" |
| 354 | + ); |
| 355 | + cy.get('[data-testid="Token-Permissions"] ~ h4').should( |
| 356 | + "contain", |
| 357 | + "Additional details / variations" |
| 358 | + ); |
| 359 | + |
| 360 | + cy.get('[data-testid="Vulnerabilities"]').should( |
| 361 | + "contain", |
| 362 | + "Vulnerabilities" |
| 363 | + ); |
| 364 | + cy.get('[data-testid="Vulnerabilities"] > div > span') |
| 365 | + .should("contain", "Increased 2.7") |
| 366 | + .and("have.css", "background-color") |
| 367 | + .and("eq", "rgb(24, 135, 84)"); |
| 368 | + cy.get('[data-testid="Vulnerabilities"] > span').should("contain", "10/10"); |
| 369 | + cy.get('[data-testid="Vulnerabilities"] ~ h4').should( |
| 370 | + "contain", |
| 371 | + "Additional details / variations" |
| 372 | + ); |
| 373 | + }); |
| 374 | +}); |
0 commit comments