Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

AbstractSession.storeCookie() support for run-time defined cookie names. #431

Merged
15 commits merged into from
Aug 13, 2020

Conversation

Tulsagrammer
Copy link

Commit b1a0fad introduced a breaking change to AbstractSession.storeCookie() for APIs and applications generating cookie names that can't be fully known at build time. The current code assumes the "=" character separating cookie name and cookie value immediately follows the value stored in tokenType. This assumption breaks down when the server generates a cookie name starting with a fixed character string followed by an additional character string generated at run time.

This proposed change continues to support static cookie names as well as dynamically generated cookie names. Imperative's test:unit was run successfully against this change.

Dynamically generated cookie names might be used by APIs and servers that can listen for connections on multiple ports, where the port has some significance to the server. If that server used a fixed character string for the cookie name, it might have difficulty distinguishing the source of a returned cookie. In our case, we have a server that generates cookie names using the string "EJESWEB_" followed by the port number on which the request was accepted.

@Tulsagrammer Tulsagrammer marked this pull request as ready for review July 30, 2020 13:57
Eric Chevalier added 2 commits July 30, 2020 09:18
…e not completely known at build time.

Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
@Tulsagrammer Tulsagrammer changed the title AbstractSession.storeCookie() updated to support cookie names that ar… AbstractSession.storeCookie() support for run-time defined cookie names. Jul 30, 2020
@Tulsagrammer Tulsagrammer marked this pull request as draft July 30, 2020 16:34
@Tulsagrammer Tulsagrammer marked this pull request as ready for review July 30, 2020 17:45
@Tulsagrammer Tulsagrammer marked this pull request as draft July 30, 2020 17:59
@Tulsagrammer Tulsagrammer marked this pull request as ready for review July 30, 2020 23:39
@codecov
Copy link

codecov bot commented Aug 2, 2020

Codecov Report

Merging #431 into master will decrease coverage by 0.31%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #431      +/-   ##
==========================================
- Coverage   82.12%   81.81%   -0.32%     
==========================================
  Files         157      157              
  Lines        7754     7616     -138     
  Branches     1459     1375      -84     
==========================================
- Hits         6368     6231     -137     
+ Misses       1382     1381       -1     
  Partials        4        4              
Impacted Files Coverage Δ
packages/rest/src/session/AbstractSession.ts 96.90% <100.00%> (+0.10%) ⬆️
...ages/rest/src/session/ConnectionPropsForSessCfg.ts 97.87% <0.00%> (-1.15%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c3766bd...5a7dd4d. Read the comment docs.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

Please add a unit test that verifies dynamic token type support to prevent a regression in the future. The test can be added in packages/rest/__tests__/session/Session.test.ts.

packages/rest/src/session/AbstractSession.ts Outdated Show resolved Hide resolved
Copy link
Member

@zFernand0 zFernand0 left a comment

Choose a reason for hiding this comment

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

LGTM!

@zFernand0
Copy link
Member

Just need to address the merge conflict, and this PR should be good to go! 😋

Eric Chevalier added 11 commits August 12, 2020 14:20
Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
…d tokenValue. Handles the case where a cookie contains "=" in the value string.

Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
… "=" delimiter.)

Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
… malformed cookie. Added unit test for partial/dynamic cookie name.

Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
…cks against values used to buiild session tokenType and tokenValue.

Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
…est.ts (trailing space).

Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
Signed-off-by: Eric Chevalier <eric@vikingsoft.com>
@Tulsagrammer
Copy link
Author

@zFernand0: I'm sorry to bug you, but I'm lost. I'm still getting "Conflicting files" on CHANGELOG.md. I just don't see a conflict: I'm just adding a change comment for my storeCookie above the existing 4.7.5 change entry. (The most recent change entry on master.) Any suggestions or advice on what I'm doing wrong?

@ChrisBoehmCA
Copy link
Contributor

ChrisBoehmCA commented Aug 13, 2020

If you're using an editor like VSCode, you should be able to try to pull master into your branch and resolve the conflict graphically. https://code.visualstudio.com/docs/editor/versioncontrol (Section Merge conflicts). The git conflict is probably something simple but I haven't pulled your branch to see. Also I think you are supposed to use a "Recent Changes" header in the changelog in pull requests and the version is assigned later after the PR is merged. Fernando can confirm

If you don't have a git "remote" set up to point to this original repository you can do something like this:

git remote add zowe https://github.com/zowe/imperative.git
git pull zowe master

@Tulsagrammer
Copy link
Author

@zFernand0: the changelog conflict has been addressed. I notice that two checks appear to have failed. Looking at the details of "Imperative CI / test (10.x, windows-latest)" it appears that the issues causing the test to fail are not related to the files in my pull request. In particular, "packages/rest/tests/session/Session.test.ts" has a PASS. As for "continuous-integration/jenkins/pr-merge", the other failing test, I have no idea what's making that test fail.

@Tulsagrammer
Copy link
Author

@zFernand0: as a follow-up to my previous message, it appears that "continuous-integration/jenkins/pr-merge" is failing on issues associated with integration testing. More specifically, "tests/src/packages/profiles/CliProfileManager.credentials.spec.ts" appears to be having problems with secure credential storage: "Couldn't create item: The secret was transferred or encrypted in an invalid way." A second issue seems to be associated with tests of CredentialManagerFactory.ts.

@sonarcloud
Copy link

sonarcloud bot commented Aug 13, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

88.9% 88.9% Coverage
0.0% 0.0% Duplication

warning The version of Java (1.8.0_212) you have used to run this analysis is deprecated and we will stop accepting it from October 2020. Please update to at least Java 11.
Read more here

@ghost
Copy link

ghost commented Aug 13, 2020

@Tulsagrammer Re-ran the GitHub and Jenkins builds, both failures were transient and the builds passed the second time. The "codecov/project" check is still failing but can be ignored, as it often shows inaccurate reports and "codecov/patch" shows that the PR has sufficient coverage.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for addressing the conflict 🙂

@ghost ghost merged commit c619027 into zowe:master Aug 13, 2020
@Tulsagrammer Tulsagrammer deleted the PSI-storeCookie branch August 13, 2020 20:53
@Tulsagrammer Tulsagrammer restored the PSI-storeCookie branch September 4, 2020 18:25
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants