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

Allow container creation via PUT #513

Closed
wants to merge 71 commits into from

Conversation

dmitrizagidulin
Copy link
Contributor

No description provided.

- WIP (fix standard warnings)
- WIP (moving oidcConfig to config.json)
- Add OIDC Issuer discovery link header on OPTIONS
- Refactor OIDC client/handler code
- Bump dep version, fix gitignore
- Integrate Sign In w WebID page with OIDC login
- Fix OIDC create user functionality
- Fix storing redirectTo URL in session
- Remove unneeded options obj (oidc.js)
- WIP (create account using webid as OIDC _id)
- Fix extraneous oidcIssuerHeader
- WIP (fix response types)
- Fix token() params
- Fix authCallback()
- WIP (switch to implicit workflow)
- WIP (fix registration configs)
- wip - Switch to authz code flow
- Move createOIDCUser to oidc-rp-client (from identity-provider)
- Implement OIDC /signout support
- Do not create a Solid account folder if OIDC user creation fails
- WIP - signin session / resume workflow
- Signin api: send 500 error if oidc client not initialized
- Remove invalid test
- Implement user creation via api
- Add username & pw auth logic to signin.js
- Add bcrypt compilation Travis CI directives
- Mount OIDC Identity Provider API into solid server routes
- Initialize multi-rp client store collections
- Change oidc packages to use github links
- Disable the certificate test for the time being
- Derive session cookie domain from root uri
- Bump oidc-op-express dep
- Output auth method at startup
- Implement injected Provider logout() behavior
- Remove legacy signout logic
- Refactoring OIDC initialization from server config in create-app
- Simplify createApp()
- Move unit tests to their own test/unit/ folder
- Refactor lib/api/authn/ files
- Move tests to test/unit/ and test/integration/
- Implement CreateOidcAccountRequest and unit tests
- Add OIDC account creation integration tests
- Extract OidcManager code to external lib
- Fix Provider Discover integration tests
- Fix existing Login workflow integration test
- Implement DiscoverProviderRequest, refactor
- Extract login logic to LoginByPasswordRequest
- Unit tests for LoginByPasswordRequest
- Implement login via either username or webid
- Add /login integration tests
- Normalize webid if needed during provider discovery
- Render Obtain Consent handlebars view
- Save provider config on startup, install nyc / code coverage
- Move options handler to before authentication or account api
- Ensure local client registered on startup
dmitrizagidulin and others added 11 commits June 7, 2017 11:21
* Add WWW-Authenticate to exposed CORS headers

* Fix 401 error handling, add tests

* Add a test for expired token error

* Update to supertest 3.0.0

* Convert 401 tests to Promise interface

* Rewrite error-pages handler, add tests

* Change 401 error logic on empty bearer token

* Return a 400 error on empty bearer token header
* Make ./data the default root folder

* Add ./data to .gitignore

* Fix typo in help text
The patch handler contains logic for multiple request body types.
Moving them to separate files facilitates adding support for more types.
The PATCH handler for application/sparql does not perform any patching,
i.e., nothing is ever written to disk.
Since our next goal is to further abstract patching code
(which includes writing), this incomplete code cannot be used.
This reduces the task of individual patch handlers
to parsing the patch and applying it.
@dmitrizagidulin
Copy link
Contributor Author

cc @dan-f @RubenVerborgh for review.

Copy link
Contributor

@dan-f dan-f left a comment

Choose a reason for hiding this comment

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

When the LDP container already exists, it looks like you re-generate the .meta file and return a 204. But based on the current implementation, the .meta file is overwritten and the rest of the contained data remains unchanged, due to how mkdirp works.

Copy link
Contributor

@RubenVerborgh RubenVerborgh left a comment

Choose a reason for hiding this comment

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

No other remarks from me; I missed the issue @dan-f found.

if (filePath.endsWith('/')) {
return callback(error(409,
'PUT not supported on containers, use POST instead'))
const statusCode = fs.existsSync(filePath) ? 204 : 201
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick, but might want to have this async?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you prefer. I used a sync operation here because exists is a pretty lightweight operation, and it avoids introducing another level of callback nesting to the function. Happy to change it tho.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, indeed… I don't mind either way. Can't wait to switch to Node 8 though, where sync and async have essentially the same syntax 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Rule of thumb is async when available for code handling a request, sync for everything else.

@dmitrizagidulin
Copy link
Contributor Author

When the LDP container already exists, it looks like you re-generate the .meta file and return a 204. But based on the current implementation, the .meta file is overwritten and the rest of the contained data remains unchanged, due to how mkdirp works.

@dan-f Are those not the expected semantics? What would you like to see happen instead?

rm('/acl-tls/write-acl/empty-acl/another-empty-folder/test-file.acl')
rm('/acl-tls/write-acl/empty-acl/test-folder/test-file')
rm('/acl-tls/write-acl/empty-acl/test-file')
rm('/acl-tls/write-acl/test-file')
rm('/acl-tls/write-acl/test-file.acl')
rm('/acl-tls/write-acl/empty-acl/test-folder2/')
Copy link
Contributor

Choose a reason for hiding this comment

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

You've got this in the before and after. Not really sure what the intention is here.


after(() => {
rm('/foo/')
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, not sure why this is in both the before and after.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's in the before and after to ensure the directory is clear before the tests run; fairly standard procedure. Happy to take it out if you think it excessive.

Copy link
Contributor

@dan-f dan-f Jun 29, 2017

Choose a reason for hiding this comment

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

I understand cleanup is necessary, but I've never had to do it both before and after a test is run. Either should suffice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Np, will take the before() out.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see, these are before/after all the tests in the block, not each test individually. I think this intersects with the issue of shared state between tests.

.then(() => {
let stats = fs.statSync(path.join(__dirname, '../resources/foo/two/'))

if (!stats.isDirectory()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just write expect(statsisDirectory()).toBe(true) if you're using the expect library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks.

let metaFilePath = path.join(__dirname, '../resources/foo/four/.meta')
let meta = fs.readFileSync(metaFilePath, 'utf8')

assert.equal(meta, containerMeta)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think @deiu has pointed this out before, but testing for graph equality based on serialization can be brittle. Better to use something like rdflib to assert that the graphs are equal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, for tests of graph equality. But there isn't any parsing or serialization taking place here. This is just straight file read/write operations.

Copy link
Contributor

@deiu deiu Jun 29, 2017

Choose a reason for hiding this comment

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

Can I point out that hardcoding .meta is probably a bad idea? I think the config options contains a variable with the name for the meta document.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's an implementation detail of the fact that node-solid-server doesn't yet use a database. It's generally best for integration tests not to assume any particular implementation.


assert.equal(meta, newMeta)
})
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing a test for the case in which there are already graphs in the container.

})

after(() => {
rm('sampleContainer/example1-copy.ttl')
Copy link
Contributor

Choose a reason for hiding this comment

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

?

})
})

it('should update existing container meta', done => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd much prefer if we didn't share state between tests. Having a test rely on the output of a previous test introduces a possible race condition, especially since, depending on the test runner, tests may be run concurrently.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually okay; within a single describe block, we can have multiple assertions (and in fact, it's in general better to split assertions as much as possible).

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not objecting to multiple assertions - I'm objecting to the fact that this test (the code in the callback passed to it) relies on the fact that some other test created some data on the file system.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, the scoping should be different. That's what I dislike about super-agent: it makes it hard to do that separation right (first create context, then assert).

@dan-f
Copy link
Contributor

dan-f commented Jun 29, 2017

@dan-f Are those not the expected semantics? What would you like to see happen instead?

Well, I'm not exactly sure, as the LDP spec doesn't seem to specify what to do when the container already exists.

That said, I'd expect either a) to recreate the container (removing the existing container entirely) or not to modify it at all. The current implementation rewrites the .meta graph and nothing else, which seems a bit unintuitive.

@dmitrizagidulin
Copy link
Contributor Author

Well, I'm not exactly sure, as the LDP spec doesn't seem to specify what to do when the container already exists.

That said, I'd expect either a) to recreate the container (removing the existing container entirely) or not to modify it at all. The current implementation rewrites the .meta graph and nothing else, which seems a bit unintuitive.

Maybe @timbl can clarify Solid semantics of PUT to a container..? (with regards to the .meta etc)?

@RubenVerborgh RubenVerborgh changed the base branch from dz_oidc to release/v4.0.0 September 3, 2017 23:33
@RubenVerborgh
Copy link
Contributor

Would need a serious rebase.

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.

4 participants