Code Monkey home page Code Monkey logo

go-dag-jose's People

Contributors

alexjg avatar decentralgabe avatar oed avatar smrz2001 avatar warpfork avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-dag-jose's Issues

Create test for ipfs-http-client

That tests creating and retrieving dag-jose objects from ipfs using the ipfs-http-client. Tests should be configurable to point either to a js-ipfs or go-ipfs daemon.

Original issue

Make a simple js script that tests the functionality.

test failure when updating to use upstream codecs which now enforce map entry sorting

I've attempted to bump the go-ipld-prime version in the go.mod file to v0.12.0 and found one test failure.

In brief

It appears to be related to stability of order of contents encoded by using dag-cbor. This changed in [email protected]: the dag-cbor codec now forces map key sorting when encoding. (Some people consider this a regression, and I frankly even agree, but have been out-voted on it.)

I suspect this isn't a major behavioural problem, and doesn't affect any downstreams, but a test failure is a test failure :)

The failure

The fulltext of the test failure is below:

--- FAIL: TestRoundTripArbitraryJOSE (1.70s)
    dagjose_test.go:463: [rapid] failed after 0 tests: (*T).FailNow() called
        To reproduce, specify -run="TestRoundTripArbitraryJOSE" -rapid.seed=1629884721185674694
        Failed test output:
    dagjose_test.go:464: [rapid] draw An arbitrary JOSE object: &dagjose.DagJOSE{payload:(*cid.Cid)(nil), signatures:[]dagjose.jwsSignature(nil), protected:[]uint8{}, unprotected:[]uint8{}, iv:[]uint8{}, aad:[]uint8(nil), ciphertext:[]uint8{}, tag:[]uint8(nil), recipients:[]dagjose.jweRecipient{dagjose.jweRecipient{header:map[string]ipld.Node{"":(*basicnode.plainMap)(0xc000c0da20)}, encrypted_key:[]uint8(nil)}}}
    dagjose_test.go:466:
                Error Trace:    dagjose_test.go:466
                                                        engine.go:203
                                                        engine.go:124
                                                        engine.go:74
                                                        dagjose_test.go:463
                Error:          Not equal:
                                expected: &dagjose.DagJOSE{payload:(*cid.Cid)(nil), signatures:[]dagjose.jwsSignature(nil), protected:[]uint8{}, unprotected:[]uint8{}, iv:[]uint8{}, aad:[]uint8(nil), ciphertext:[]uint8{}, tag:[]uint8(nil), recipients:[]dagjose.jweRecipient{dagjose.jweRecipient{header:map[string]ipld.Node{"":(*basicnode.plainMap)(0xc000c0da20)}, encrypted_key:[]uint8(nil)}}}
                                actual  : &dagjose.DagJOSE{payload:(*cid.Cid)(nil), signatures:[]dagjose.jwsSignature(nil), protected:[]uint8{}, unprotected:[]uint8{}, iv:[]uint8{}, aad:[]uint8(nil), ciphertext:[]uint8{}, tag:[]uint8(nil), recipients:[]dagjose.jweRecipient{dagjose.jweRecipient{header:map[string]ipld.Node{"":(*basicnode.plainMap)(0xc000c0dec0)}, encrypted_key:[]uint8(nil)}}}

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -23,8 +23,8 @@
                                       (basicnode.plainMap__Entry) {
                                +       k: (basicnode.plainString) "",
                                +       v: (*basicnode.plainString)("")
                                +      },
                                +      (basicnode.plainMap__Entry) {
                                        k: (basicnode.plainString) (len=1) "?",
                                        v: (*basicnode.plainString)(<already shown>)
                                -      },
                                -      (basicnode.plainMap__Entry) {
                                -       k: (basicnode.plainString) "",
                                -       v: (*basicnode.plainString)("")
                                       }
                Test:           TestRoundTripArbitraryJOSE

Recommendation

I suspect the correct action to do here is patch the test expectations to just have content which is in the canonical order that dag-cbor will now sort things into.

want encoder and decoder methods

It would be nice to have this code export some functions called Encode and Decode that match https://pkg.go.dev/github.com/ipld/[email protected]/codec#Encoder and https://pkg.go.dev/github.com/ipld/[email protected]/codec#Decoder.

This would be a prerequisite for getting this to land as a plugin in go-ipfs, because there, things need to conform to those function interfaces so they can be put in a registry map keyed by their multicodec indicator code. (The git plugin is an example of what gets wired up: https://github.com/ipfs/go-ipfs/blob/ae09459e3926d687599638abdb379e8627b53509/plugin/plugins/git/git.go#L40-L41 )

I think the StoreJOSE and LoadJOSE functions are probably close, so all the right logic exists somewhere, but the interfaces don't quite line up.

Validate / update the go-dag-jose plugin

We need to confirm the following properties:

We should run the tests with the latest 0.9.0 go-ipfs release. We need to manually compile the go plugin.

Basic testing with go-ipfs

We need to make sure that go-ipfs with a go-dag-jose plugin works the same as js-ipfs from the perspective of the ipfs-http-client. We should also make sure that some basic commands in go-ipfs works as expected.

We should have a basic script that creates a dag-jose object, puts it into the dag (ipfs.dag.put), retrieves it from the dag (ipfs.dag.get), and confirms that the retrived object is correctly formatted, and the same JWS object get's the same CID in both cases.

Run the tests:

  • on js-ipfs daemon
  • on go-ipfs daemon

go-ipfs cli

We want to be able to retrieve a dag-jose object from the ipfs cli and have it outputted in the console. When
ipfs dag get <dag-jose-cid> is exectued we should see the dag-jose object outputted in json format.

Note that this is not a strict requirement for js-ceramic to work properly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.