Skip to content

Securesign 922#53

Merged
petrpinkas merged 5 commits intomainfrom
SECURESIGN-922
Jul 17, 2025
Merged

Securesign 922#53
petrpinkas merged 5 commits intomainfrom
SECURESIGN-922

Conversation

@kdacosta0
Copy link
Member

@kdacosta0 kdacosta0 commented May 13, 2025

  • Rekor search UI testing - browser [Chrome / Safari / Edge / Firefox]

Summary by Sourcery

Migrate and refactor the Rekor Search UI end-to-end tests to use Playwright for real cross-browser support, update configuration and build scripts, and clean up obsolete dependencies

Enhancements:

  • Switch UI tests from rod to playwright-go and introduce a generic Browser/BrowserTest abstraction
  • Add multi-browser support (Chrome, Firefox, Safari, Edge) configurable via environment variables
  • Refactor search workflows into reusable methods for navigation, input, screenshot capture, and pagination handling
  • Extend API configuration with TEST_FIREFOX, TEST_SAFARI, and TEST_EDGE defaults
  • Update Makefile to install Playwright dependencies and add a setup target

Build:

  • Add playwright-go dependency and remove rod/got from go.mod
  • Bump various indirect module versions and add a replace for go-jose v4

* Rekor search UI testing - browser [Chrome / Safari / Edge / Firefox]

* refactor
@sourcery-ai
Copy link

sourcery-ai bot commented May 13, 2025

Reviewer's Guide

This PR replaces the rod-based UI tests with a Playwright-Go framework, introduces a BrowserTest abstraction for reusable search routines, adds multi-browser support via environment variables, simplifies test data extraction using regex, and updates dependencies and build scripts accordingly.

Class diagram for BrowserTest abstraction and Playwright integration

classDiagram
    class BrowserTest {
        +browserName: string
        +page: playwright.Page
        +Launch()
        +Navigate(url string)
        +SearchByEmail(email string)
        +SearchByHash(hash string)
        +SearchByLogIndex(index string)
        +SearchByUUID(uuid string)
        +SearchByCommitSHA(sha string)
        +TakeScreenshot(name string)
    }
    class Playwright {
        +Install()
        +LaunchBrowser(name string)
        +Close()
    }
    BrowserTest --|> Playwright : uses
Loading

Class diagram for updated environment variable configuration

classDiagram
    class Values {
        +SetDefault(key string, value string)
        +AutomaticEnv()
    }
    Values : +TestFirefox = "TEST_FIREFOX"
    Values : +TestSafari = "TEST_SAFARI"
    Values : +TestEdge = "TEST_EDGE"
    Values : +HeadlessUI = "HEADLESS_UI"
    Values : +RegistryImage = "REGISTRY_IMAGE"
    Values : +TsaURL = "TSA_URL"
    Values : +ManualImageSetup = "MANUAL_IMAGE_SETUP"
    Values : +CosignImage = "COSIGN_IMAGE"
    Values : +DockerRegistryUsername = "REGISTRY_USERNAME"
    Values : +DockerRegistryPassword = "REGISTRY_PASSWORD"
Loading

File-Level Changes

Change Details Files
Replace rod with Playwright-Go for browser automation
  • Removed rod and got imports and code
  • Added playwright-go imports and Playwright runner initialization
  • Implemented CreateBrowser, Navigate, Screenshot, and Close methods
  • Added BrowserType enum and headless launch logic
test/rekorsearchui/rekor_search_sign_verify_test.go
go.mod
scripts/Makefile
Refactor UI tests into a BrowserTest abstraction
  • Introduced BrowserTest and TestData structs
  • Moved per-browser setup/teardown into NewBrowserTest and Close
  • Refactored individual search flows into performSearch and findEntryAcrossPages
  • Created TestEmailSearch, TestHashSearch, TestLogIndexSearch, TestUUIDSearch, TestCommitSHASearch methods
test/rekorsearchui/rekor_search_sign_verify_test.go
Enable cross-browser testing via configurable environment variables
  • Added GetBrowsersToTest reading TEST_FIREFOX, TEST_SAFARI, TEST_EDGE
  • Wrapped test suites in a loop over selected BrowserTypes
  • Updated default env var values in pkg/api/values.go
test/rekorsearchui/rekor_search_sign_verify_test.go
pkg/api/values.go
Simplify test data extraction using regex
  • Replaced JSON unmarshal and manual string parsing with regexp matching
  • Adjusted cosign and gitsign invocation for SHA, log index, UUID, and hash extraction
  • Logged extracted values for debugging
test/rekorsearchui/rekor_search_sign_verify_test.go
Update dependencies, build scripts, and linter settings
  • Added playwright-go dependency; removed rod, got, and related modules
  • Extended Makefile with a setup target to install Playwright and its dependencies
  • Cleaned up indirect modules in go.mod/go.sum
  • Adjusted .golangci.yml linter configuration
go.mod
go.sum
scripts/Makefile
.golangci.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@kdacosta0
Copy link
Member Author

Waiting for upstream to resolve email search limitation issue

Signed-off-by: Kristián Da Costa Menezes <113685889+kdacosta0@users.noreply.github.com>
@kdacosta0 kdacosta0 marked this pull request as ready for review July 7, 2025 13:37
@kdacosta0 kdacosta0 requested a review from osmman July 7, 2025 13:37
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kdacosta0 - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `scripts/Makefile:40` </location>
<code_context>
-tuf-repo:
-	@echo "Running manual TUF repository test..."
-	go test -v ./test/tuftool
+setup:
+	@echo "Installing Playwright dependencies..."
+	@npm install @playwright/test
+	@npx playwright install --with-deps
+	@go run github.com/playwright-community/playwright-go/cmd/playwright install

-.PHONY: build test test-tuf-repo all 
</code_context>

<issue_to_address>
The setup target mixes npm and Go-based Playwright installation.

Standardize on either npm or Go for Playwright installation to prevent redundancy and version conflicts.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
setup:
	@echo "Installing Playwright dependencies..."
	@npm install @playwright/test
	@npx playwright install --with-deps
	@go run github.com/playwright-community/playwright-go/cmd/playwright install
=======
setup:
	@echo "Installing Playwright dependencies..."
	@npm install @playwright/test
	@npx playwright install --with-deps
>>>>>>> REPLACE

</suggested_fix>

### Comment 2
<location> `pkg/api/values.go:28` </location>
<code_context>
 	RegistryImage    = "REGISTRY_IMAGE"
 	TsaURL           = "TSA_URL"
 	HeadlessUI       = "HEADLESS_UI"
+	TestFirefox      = "TEST_FIREFOX"
+	TestSafari       = "TEST_SAFARI"
+	TestEdge         = "TEST_EDGE"

 	// 'DockerRegistry*' - Login credentials for 'registry.redhat.io'.
</code_context>

<issue_to_address>
New browser test environment variables default to 'true'.

Defaulting these variables to 'true' could cause tests to run and fail if the browsers aren't present. Consider using 'false' as the default or clearly documenting the browser requirements.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
	Values.SetDefault(TestFirefox, "true")
	Values.SetDefault(TestSafari, "true")
	Values.SetDefault(TestEdge, "true")
=======
	Values.SetDefault(TestFirefox, "false")
	Values.SetDefault(TestSafari, "false")
	Values.SetDefault(TestEdge, "false")
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@kdacosta0 kdacosta0 requested a review from petrpinkas July 9, 2025 11:31
Signed-off-by: Kristián Da Costa Menezes <113685889+kdacosta0@users.noreply.github.com>
Signed-off-by: Kristian Da Costa Menezes <kdacosta@redhat.com>
@kdacosta0 kdacosta0 changed the title Securesign 922 (#52) Securesign 922 Jul 16, 2025
@petrpinkas petrpinkas merged commit 4e18425 into main Jul 17, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants