Skip to content
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

feat: Add cookie support for Pull mode jobs executed from NuvlaEdge #399

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ignacio-penas
Copy link
Contributor

Closes sixsq/tasklist#3225

Copy link
Contributor

github-actions bot commented Oct 25, 2024

Test Results

34 tests  ±0   34 ✅ ±0   1s ⏱️ ±0s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit e81baf3. ± Comparison against base commit 0b1e370.

♻️ This comment has been updated with latest results.

@schaubl schaubl marked this pull request as draft October 28, 2024 11:24
@ignacio-penas ignacio-penas marked this pull request as ready for review October 31, 2024 07:27
def _init_nuvla_api(self):
# true unless header authentication is used
reauthenticate = self.args.api_authn_header is None
cookies = os.getenv("JOB_COOKIES", "")
persist_cookie = cookies != "" and cookies is not None
Copy link
Contributor

Choose a reason for hiding this comment

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

could be simplified with

Suggested change
persist_cookie = cookies != "" and cookies is not None
persist_cookie = bool(cookies)

Copy link
Contributor

@schaubl schaubl left a comment

Choose a reason for hiding this comment

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

I would use a tmpfile for the cookie file.

But in fact, why writing the cookie to a file ?

After the Api instance is created it's possible to do:

self.api = Api(...)
self.api.session.cookies.set_cookie(cookie)

In this case it needs to be a (single) cookie like returned by the Set-Cookie HTTP header.
But you can load a mozilla cookie file in memory with BytesIO (or StringIO):

self.api = Api(...)
self.api.session.cookies = MozillaCookieJar()
self.api.session.cookies._really_load(BytesIO(cookies), '', ignore_discard=True)

@schaubl
Copy link
Contributor

schaubl commented Nov 5, 2024

Please also see the review comment in the other PR: nuvlaedge/nuvlaedge#214 (review)

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