-
Notifications
You must be signed in to change notification settings - Fork 11
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
Permit OSCAL Object URL as URL Parameter #143
Conversation
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.
Looking good so far! I had a few comments.
I also wonder if we need to test for both cases when a url
is provided vs when it is not? Could we primarily test that things load properly when we load a url and just have a few tests to make sure things work otherwise?
src/test-data/SystemData.js
Outdated
@@ -1,4 +1,8 @@ | |||
import { metadataTestData, responsibleRolesTestData } from "./OtherData"; |
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.
In develop
, the change from OtherData
-> CommonData
was done already I believe.
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.
If it was already done, I think I pulled from the develop branch prior to the change being made, so that's why you see the renaming in my files.
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.
Oh maybe do a git pull rebase
to be sure?
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.
Even a git pull origin develop
that does a merge commit should help resolve that.
src/test-data/Urls.js
Outdated
export const defaultOSCALProfileUrl = | ||
"https://raw.githubusercontent.com/usnistgov/oscal-content/master/nist.gov/SP800-53/rev4/json/NIST_SP-800-53_rev4_MODERATE-baseline_profile.json"; |
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.
Is this the same as parentUrlTestData
? Will it always be?
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.
Yes, this is the same as parentUrlTestData
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.
It seems we do not use parentUrlTestData
anywhere. Can we just get rid of it?
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.
That depends on how we handle the default viewer urls
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.
Hey @mikeisen1 please try to let the thread authors resolve conversations. I think I still need an explanation for exactly what we plan to use this for, why the value is the same, and why it's a different variable. Are we expecting to eventually use different URLs? If the answer is "it depends" then I think we should talk about the assumptions and design and make sure we understand what it depends on and what we've chosen here. I am missing an understanding of that justification and it seems that @tuckerzp may be as well.
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.
I am not sure why the value is the same and they're in different variables. Both parentUrlTestData
and defaultOSCALProfileUrl
have been in the codebase since before I have been working on the project.
My "depends" reply was in response to Zach Tucker's reply. When I moved the default urls back to the OSCALLoader file, I kept their original scope (none of them had export
). So, I would only delete parentUrlTestData
if I moved defaultOSCALProfileUrl
back to the OSCALLoader file and did not export it. As for whether they will both always be the same, I think they would only be different if we want the urls used in the stories and tests to be different from the default viewer urls.
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.
Both
parentUrlTestData
anddefaultOSCALProfileUrl
have been in the codebase since before I have been working on the project.
So that is an issue that I have had to deal with a few times. A lot of changes were made and thought out long before we started on project. Using Git Blame
and checking the history for why something was done and when is super helpful to get an idea of why something may or may not be important.
From looking purely at the code you have added, parentUrlTestData
is not used anywhere as of now. defaultOSCALProfileUrl
seems to have replaced all those places where it was used. Going off of conversations above, defaultOSCALProfileUrl
is not really needed in Urls.js
, so parentUrlTestData
could be needed again.
With that said, I am curious why they are the same value and in different variables. Maybe look into why they might be similar?
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.
At a high level, the majority of these test changes are really testing whether a different source URL loads correctly, not necessarily related to whether or not that source URL was provided as a URL parameter when making the request for the viewer in a browser, which we probably should not be testing with component tests.
While those additional tests may be valuable, we might want to consider whether we want to duplicate all tests with different expectations, or restructure the existing tests to follow a pattern of "for this URL, here are the expected values for the different elements", keeping in mind that some sources may not be expected to render certain elements at all.
That close tie of the source URL and expected rendering might also lend itself to the source URL being 'close to the expectations', i.e. in the test file, rather than in a separate URL file.
See a few other line-specific comments.
When looking at the code I thought the same thing.
I also wonder if it is a good idea to test for specific things to be found when loading external components that, as we have seen before, change pretty frequently. |
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.
As @tuckerzp mentioned, there are a few changes here that I am wondering if they're a result of the merge conflict and the diff is off. Can you update with the develop
branch and resolve the merge conflicts then push again?
src/test-data/SystemData.js
Outdated
@@ -1,4 +1,8 @@ | |||
import { metadataTestData, responsibleRolesTestData } from "./OtherData"; |
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.
Even a git pull origin develop
that does a merge commit should help resolve that.
@rgauss @kylelaker Just to keep history clean, would this be a good place to squash and force push the |
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.
Has line ending issue been addressed?
example/public/robots.txt
Outdated
# https://www.robotstxt.org/robotstxt.html | ||
User-agent: * | ||
Disallow: / | ||
# https://www.robotstxt.org/robotstxt.html | ||
User-agent: * | ||
Disallow: / |
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.
For example
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.
Line ending issue was addressed at least on my end.
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.
If it is not line ending issue, why is this change occurring? It seems like these files should not need to be deleted and then added in an identical way.
src/components/OSCALLoader.js
Outdated
export function getRequestedUrl() { | ||
// Returns url parameter provided by the browser url, if | ||
// it exists. If the url parameter exists, we want to | ||
// override the default viewer url. | ||
return new URLSearchParams(window.location.search).get("url"); | ||
} | ||
|
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.
Now that this is being exported, is JSDoc needed here?
Add functionality that allows users to specify a URL parameter in the browser, for each of the OSCAL viewers. Specifying a URL parameter will override the provided default URLs for the corresponding viewer.
Rename urlToLoad function to loadDefaultOrExternalUrl to make it easier to understand its purpose. Additionally, added comment explaining what the function does as well as its purpose.
Move default components urls back to OSCALLoader so they stay separated from the test and storybook data. Rename and modify urlToLoad as well as its description to improve overall code readability.
Create the UrlParameter test file to test the getRequestedUrl function in the OSCALLoader, allowing us to determine whether the method of obtaining the url parameter works as expected.
c140a27
to
a37af31
Compare
Add JSDoc documentation to getRequestedUrl function, as it is now part of the public API and needs to be documented.
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.
Looks good
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.
Thanks for your work on this! Looking really good!
Adjustments were made to allow for someone to pass in a url parameter in the browser window for each of the OSCAL viewers, overriding the corresponding default url. This allows for any data contained in a valid url to be loaded into an OSCAL viewer, lending greater flexibility to what can be displayed.
To input an external url and display its data, add the following to the end of the browser url:
?url=<external-url>
.Listed below are example files which can be used as external URLs:
Note that the component viewer example does not load properly due to an issue with one of the sources in the data. However, there were no other examples, so just seeing whether the url in the OSCAL Component Viewer url box changed will have to do for now. Additionally, the above are just examples, as there are other urls for each of the Catalog, SSP, and Profile viewers that can be used.
This will resolve #134