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

New user command #10

Merged
merged 24 commits into from
May 23, 2016
Merged

New user command #10

merged 24 commits into from
May 23, 2016

Conversation

bookdude13
Copy link
Member

No description provided.

@bookdude13
Copy link
Member Author

Addresses #6.

@@ -6,15 +6,23 @@ extern crate git2;
use std::env;
use std::path::Path;

fn main2() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rebase on top of issue 4 when that's done, and make sure that src/main.rs is all cleaned up afterwards.

@rjayatilleka
Copy link
Contributor

Kaaaay, I ripped it apart. Good luck :)

@rjayatilleka
Copy link
Contributor

Oh and add some integration tests, like the ones in tests/initialize_project.rs.

@@ -1,17 +1,38 @@
/// Structure to represent a Proton Project.
/// This is what will be written to a Protonfile at the project root.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be right next to Project. Move User down below pub struct Project and above impl Project.

}
}

// Adds a user to the project
Copy link
Contributor

Choose a reason for hiding this comment

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

Doc comment (3 slashes)

@bookdude13
Copy link
Member Author

If name is a &String, should User.name be of type &String as well? That can cause a fair amount of manual lifetime management

@rjayatilleka
Copy link
Contributor

No, forget everything I said about references earlier. Just keep everything as Strings like earlier. You had it right before, because that String goes from Args -> run_new_user -> new_user -> User -> Project -> disk, and then is never used again. So it's totally fine.

@@ -1,17 +1,38 @@
/// Structure to represent a Proton Project.
/// This is what will be written to a Protonfile at the project root.
#[derive(Debug, RustcEncodable, RustcDecodable)]

Copy link
Contributor

Choose a reason for hiding this comment

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

Get rid of this blank line. Comments should be directly next to what they're doc-ing. Otherwise it just looks weird. Do you not think so?

Copy link
Member Author

Choose a reason for hiding this comment

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

To me it looks weird next to the #[derive()] statement. Move the derive inside the struct? Otherwise it does look better than having the space

Copy link
Contributor

@rjayatilleka rjayatilleka May 20, 2016

Choose a reason for hiding this comment

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

/**
 * Merges stuff
 * @param dataIds
 */
@Override
public String runMerge(List<String> dataIds) throws TException {

Idk, it looks normal to me to not have a line there in Java. Well, do it however you want. Maybe we should run rustfmt on it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nah, don't bother. Looks pretty good w/o the blank line

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you even move the derive? I don't think you can. Though you shouldn't anyway, it would be different from everything else. You can move the doc comment into the struct by changing it to use //!, but again, taht would be inconsistent.

Copy link
Contributor

@rjayatilleka rjayatilleka May 20, 2016

Choose a reason for hiding this comment

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

Anyway, for now, just leave the line there. We can try rustfmt out later, in a different issue.

@@ -43,3 +56,13 @@ impl PartialEq for Project {

impl Eq for Project {
}

impl PartialEq for User {
Copy link
Contributor

Choose a reason for hiding this comment

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

Get rid of both PartialEq and Eq impls. Add #![derive(Eq)] to Project and User.

@rjayatilleka
Copy link
Contributor

Sort of. You did find_user. I should really just read the code before I comment.

  1. User should contain a Vec for keys to handle the one to many.
  2. You need to implement a lookup_user_by_pub_key, and then check that on new user.
  3. It doesn't look like you're using find_user anywhere. I don't think its actually necessary?
  4. Make sure to use deriving on the Eq traits. We already let them get out of sync with the actual data: Project's eq impl doesn't consider the users.

@bookdude13
Copy link
Member Author

1 and 2: Could we use a HashSet or HashMap, with the public key being the key and the user being the value? That takes care of uniqueness of the key, and might make the lookup simpler
3: Using it in the test to check that the user was added properly. Thought it might be helpful to have as well, so I put it within the Project implementation.
4. Will do. Didn't know about that derive.

@rjayatilleka
Copy link
Contributor

Sounds good. So, something like this:

  • Project
    • name : string
    • username_to_user : map<string, User>
    • pub_key_to_username : map<string, string>
  • User
    • Name (this will be a duplicate storage, but its okay)
    • (in the future) permissions, admin, etc

Can we JSON en/decode the in built hash maps? -- Yes we can, the traits are implemented for hashmap in the rustc-serialize package that we use.

Then we need two commands instead. new-user <username> and add-key <username> <pub-key>. Usernames should be unique. This is kinda complicated, but its necessary if we want one user to many keys.

Do we actually want that? I think it's actually better to just make it one to one, because then its less complicated for the users. I mean, we're going to be distributing the private key to every person doing sequencing anyway (at least, I can't think of another way to do it. We can just call it a password and tell them to plug it in when they open the GUI). It's not like they're going to use the private keys for general use on their own computers.

@bookdude13
Copy link
Member Author

I'm alright with keeping it simple and making it one to one. If they use multiple systems, they will just have to copy the private key manually.

That would make Project and User look the same as before, just with added checks inside add_user()

@rjayatilleka
Copy link
Contributor

Yup, sounds good.

@rjayatilleka
Copy link
Contributor

Now find user is only checking if the name AND key are equal. You need to check if name OR key are equal.

}

/// Creates a temporary directory to run a test out of
/// and initializes a new project inside this directory
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't initialize a new project.

@bookdude13
Copy link
Member Author

Thanks, good catch. Just in time to make my tests pass too

@bookdude13
Copy link
Member Author

Good?

@rjayatilleka
Copy link
Contributor

Almost good. The only thing I noticed was in the tests was that you when you reset the current directory, you only go up to ... TempDir library makes a directory in the environment temp dir, so /tmp generally. So going up isn't correct. You want to save the current directory, then return directly to the saved directory.

But actually, I don't think you need that in the first place. Tests shouldn't depend on the directory they're in, unless they set it up themselves. So you can probably just get rid of all the directory resets. After that, LGTM.

@rjayatilleka
Copy link
Contributor

And let me check real quick if there's a way to specify how many threads to use in the cargo.toml.

@rjayatilleka
Copy link
Contributor

And no, there's not currently a way to set the RUST_TEST_THREADS in the cargo.toml (see rust-lang/rust#25636), so just forget about it. We might want to add a makefile to wrap around cargo, but we can think about that later if we need.

@rjayatilleka
Copy link
Contributor

Great!

@bookdude13
Copy link
Member Author

Whoops, needs to commit changes still

@rjayatilleka
Copy link
Contributor

Oh k. Well, go ahead and merge when you're ready.

@bookdude13 bookdude13 merged commit efc7867 into master May 23, 2016
@bookdude13 bookdude13 deleted the iss6 branch May 23, 2016 01:07
@bookdude13 bookdude13 mentioned this pull request May 23, 2016
bookdude13 added a commit that referenced this pull request May 20, 2017
* Added name to authors (#4)
* Name (#7)
* Added Vlad to authors list (#10)
* Overhaul of structure to use DAOs and database for backend storage (#11)
* Initial database implementations (#12)
* Updated README (#14)
* Working code for 2016 show (#19)
* Created initial 'it works' test
* Restructured into separate tests. 'is-working' tests complete?
* Restructured 'all working' test
* Added more tests. Reorganized again
* One more test
* Added test for seq sec editor added on perm change. Implemented; passing
* All tests implemented except working and 0 sections
* All tests passing
* Restructured so sequence not returned on resection
* Converted main code to new permissions api
* Tests using new api. Removed check for sequence section editor. Some tests failing
* All tests passing
* Removed editor from sequence_section type
* Tests now want seq sec in range [0, numSections)
* SeqSec now 0-indexed. Removed last traces of editor field
* Updated README and fixed error in main
* Added checks
* Moving towards Fixtures instead of 2d blocks of sequence data
* Restructured to use DAOs and database setup instead of storing in flat files
* Added initial database backup
* Postgres connection working in channel dao
* Generalized common functionality
* Updated names, public instead of private key, uid for list-permissions
* Init project returns generated public key
* Updated database definition
* Looser Cargo package versions for upgrading/good documentation
* Adding initial user mostly implemented. Util function to gen pub/priv keys
* Store both pub/priv key. Trim before compare. Get uid from key started
* Permission handling stuff. PermissionEnum is string now for simplicity
* new-user fully implemented
* A little cleanup of tests; moving towards using again
* Removed unused imports. New return type for get-uid
* PermissionEnum updated. Preliminary work on add_sequence done
* new_sequence working?
* get_sequence command added to main
* new-layout function set up
* Reading layout from file. Locations and rotations checked
* Adding layout implemented. Transactions/removing not implemented
* Layout as of 11/21/2016 added
* Project in db behind DAO now as well. General cleanup
* set-sequence-layout working
* Existential dao functions
* Channel data now in separate table
* Moved db backups to separate folder
* get-layout-id command added, not implemented
* Finished implementing add-sequence
* get-playlist-data implemented
* new-vixen-sequence working. Nullable values changed to options.
* Updated Cargo.toml
* Added seqid to playlist output
* Changed the format of playlist data
* Added music file to playlist outputted data
* Made functional again after rebase
* Added sequence duration to Sequence object for accurate num_frames calc
* Added internal channel to Channel type and layout reading
* Patching stuff
* Added current db backup with internal channel
* Patching working now; hackish fix
* Added patch file
* Updated layout and patch
* Working show backed up
* Stopped copying music over
* Using postgres FUNCTION for patching
* Added DB with FUNCTION in last commit added
* New patch
* Added newer patches
* main.rs alphabetized. Added get-project command
* Cleaned up warnings
* More verbose patching
* Added SQL to reset database to clean state
* Fixed error with reading file as string
* WORKINGgit st!
* Working show backup
* Adding admin key for 1202 backup
* Actual working show backup (whoops)
* add-sequence turned into insert-sequence
* Udated patch
* Print statemets for verbosity
* 12_03 patch
* Different format for outputting playlist data
* Removed public keys from repo
* New sequences don't copy their music files to a Music/ directory
* Version now 0.19.1 as per SemVer (#33)
* Adding beginning of testing framework post-overhaul (#32)
* Documentation (#28)
* Removed rebase artifacts. Updated version in Cargo.lock (#34)
* Permissions checks moved from the second-tier functions to main.rs (#35)
* Permissions checks moved from the second-teir functions to main.rs
* Fixes issues to moving permissions check
* Updated version numbers for dependencies (removing wildcards) (#36)
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.

2 participants