loginFromUri with headless automatic testing


#1

I had tests setup that would copy a pre-setup MockVault file to the temp directory and login with URIs I had saved when I set it up.

This morning I tried out safe_app_nodejs 0.10.0 but I get a serialization error when calling loginFromUri. I guess this might be due to a change in how the MockVault binary file works. I now want to create a new MockVault file, and I used to do that with the latest version of the browser and running a script that would authorize an app, then save the MockVault and the URI response from the authenticator. However, the last browser version (master branch of safe_browser) doesn’t seem to be updated to use the 0.10.0, is that correct?


Then, I once again looked into the tests from safe_app_nodejs:

One of the tests runs loginFromUri with a URI from a constant. Can someone explain how this works? (I guess @bochaco or @joshuef set this up.) Does this use a MockVault from somewhere, or where are those URIs generated from?

I might have asked this before, but I can’t recall when or where.


#2

This is correct @bzee, we re working on it, and this is all part of the new release of the browser we’ve been working on for some weeks now. The issue you are having is because safe-app-nodejs v0.10.0 upgrades safe_app lib which changed the encoding for the auth URIs from base64 to base32, so as you already realised you’ll need the browser with new and compatible safe_authenticator lib.

This works in a very similar way to how you explained you’ve been doing for your tests, we generate an auth URI with the browser and save it in a constant, the only difference is that in our tests (the ones that use those constants) we don’t really try to connect to the mock (since we don’t store a mock like you), we just use them to test the decoding functions of safe_app but we don’t try to send any type of request really to the mock network with such an instance. For doing the vast majority of the other tests we use loginForTest which generates some mock account in the mock file and we can then do any type of operations on it: https://github.com/maidsafe/safe_app_nodejs/blob/master/test/helpers.js#L45


#3

Great, thanks for explaining!

Is there any way I could do this, or should I just be patient for the new browser version? :wink:


#4

If you wanna give it a try by upgrading safe_authenticator in app/package.json to 0.9.0 (note you need to remove the v prefix).


#5

I updated the package.json, cleaned the repo and installed everything, then packaged it. Running the browser with --mock as well as --live gives this:

I guess I will be patient then! :smiley:


#6

oh yeah, ok, try to also upgrade safe-app-nodejs in app/package.json to v0.10.0


#7

Thank you very much! That did the trick… I can now use the SAFE Browser again to build myself a fresh MockVault!


#8

Excellent! I don’t think you really need to build a new mock, just to be clear, the only thing you need is just a new auth URI with the new encoding so it’s compatible with safe-app-nodejs v0.10.0. So if you use your old mock files and generate an authorisation response again it should work, and you should be able to access all the data you have in that mock, I’ve tried this myself and didn’t have any issues.


#9

I can confirm! Indeed, my ‘old’ MockVault can be used! Thanks a lot of your help.