-
-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/#236 cookies #242
Merged
Merged
Feature/#236 cookies #242
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
985cd3f
Stashed
ziflex c38ada9
Merge branch 'master' into feature/#236-cookies
ziflex 815e0c7
Added KeepCookies option to CDP driver
ziflex 6d468c3
Added LoadDocumentParams
ziflex efb3791
Added COOKIE_GET and COOKIE_SET methods
ziflex 165fec4
Added support for cookies
ziflex 89cb63a
Updated README
ziflex 30e7da2
Removed e2e filter
ziflex 62b54b2
Fixed issues
ziflex 1354ff0
Updated example file
ziflex 9e737dd
Set version of Go for compilation stage to stable
ziflex 98653c9
Added http.SameSite polyfill
ziflex 776ae96
Merge branch 'master' into feature/#236-cookies
ziflex ba7ee85
Updated tests
ziflex 72cfbb9
Fixed formatting
ziflex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
LET url = @dynamic | ||
LET doc = DOCUMENT(url, { | ||
driver: "cdp", | ||
cookies: [{ | ||
name: "x-e2e", | ||
value: "test" | ||
}, { | ||
name: "x-e2e-2", | ||
value: "test2" | ||
}] | ||
}) | ||
|
||
COOKIE_DEL(doc, COOKIE_GET(doc, "x-e2e"), "x-e2e-2") | ||
|
||
LET cookie1 = COOKIE_GET(doc, "x-e2e") | ||
LET cookie2 = COOKIE_GET(doc, "x-e2e-2") | ||
|
||
LET expected = "nonenone" | ||
LET actual = TYPENAME(cookie1) + TYPENAME(cookie2) | ||
|
||
RETURN EXPECT(expected, actual) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
LET url = @dynamic | ||
LET doc = DOCUMENT(url, { | ||
driver: "cdp" | ||
}) | ||
|
||
LET cookiesPath = LENGTH(doc.cookies) > 0 ? "ok" : "false" | ||
LET cookie = COOKIE_GET(doc, "x-ferret") | ||
LET expected = "ok e2e" | ||
|
||
RETURN EXPECT(expected, cookiesPath + " " + cookie.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
LET url = @dynamic | ||
LET doc = DOCUMENT(url, { | ||
driver: "cdp", | ||
cookies: [{ | ||
name: "x-e2e", | ||
value: "test" | ||
}] | ||
}) | ||
|
||
LET cookiesPath = LENGTH(doc.cookies) > 1 ? "ok" : "false" | ||
LET cookie = COOKIE_GET(doc, "x-e2e") | ||
LET expected = "ok test" | ||
|
||
RETURN EXPECT(expected, cookiesPath + " " + cookie.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
LET url = @dynamic | ||
LET doc = DOCUMENT("0.0.0.0:8081", { | ||
driver: "cdp" | ||
}) | ||
|
||
COOKIE_SET(doc, { | ||
name: "x-e2e", | ||
value: "test" | ||
}) | ||
|
||
LET cookie = COOKIE_GET(doc, "x-e2e") | ||
LET expected = "test" | ||
|
||
RETURN EXPECT(expected, cookie.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/MontFerret/ferret/pkg/compiler" | ||
"github.com/MontFerret/ferret/pkg/drivers" | ||
"github.com/MontFerret/ferret/pkg/drivers/cdp" | ||
) | ||
|
||
func run(q string) ([]byte, error) { | ||
comp := compiler.New() | ||
program := comp.MustCompile(q) | ||
|
||
// create a root context | ||
ctx := context.Background() | ||
|
||
// we inform the driver to keep cookies between queries | ||
ctx = drivers.WithContext( | ||
ctx, | ||
cdp.NewDriver(cdp.WithKeepCookies()), | ||
drivers.AsDefault(), | ||
) | ||
|
||
return program.Run(ctx) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused imports here