Commit Graph
160 Commits
Author SHA1 Message Date
Jeff Mitchell 8de5371499 Enable UI handling logic with dev passthrough directories. (#145)
* Enable UI handling logic with dev passthrough directories.

* Add tests and fix a couple of things
2020-06-24 16:06:19 -04:00
Jim 6641244734 add support for WithVersion option to updates (#126) 2020-06-24 12:33:49 -04:00
Michael Gaffney c110c86ee5 Add function to check if db error is a check constraint violation (#142) 2020-06-23 18:00:50 -04:00
Jeff Malnick 6c2a17c845 feat: use root path for passthrough (#141) 2020-06-23 10:34:07 -07:00
Jeff Mitchell 993a6f1680 Remove "projects" from grant strings (#143)
This removes the ability for a grant string to switch projects, in
accordance with our updated design. It mostly removes code, with a few
test fixes, and also adds one additional check (and test) to ensure a
grant errors rather than do-nothing succeeds if both id and type are
empty.
2020-06-23 11:28:44 -04:00
Todd Knight a02222c1f0 Adding List functionality for projects. (#140) 2020-06-23 07:04:44 -07:00
Todd Knight 0c8385b423 Updating TxHandler to accept a reader as well in order to support reads inside the same transactions as writes. (#139) 2020-06-22 13:27:26 -07:00
Michael Gaffney 6908f7a7a2 Use standard column names (#138) 2020-06-22 13:54:55 -04:00
Todd Knight 766c174fe9 Implement List Groups (#133)
* Implement List Groups

* Updating ListGroup's comments and tweaking variable name.
2020-06-22 10:46:45 -07:00
Todd Knight 5b1e4a680d Create Role CUDLR API and SDK (#135)
* Implement the Role CRUD API.

* Implement the Role List API.

* Adding Roles SDK.
2020-06-22 06:56:27 -07:00
Michael Gaffney 1023c90729 Enforce auth_account to iam_user plus iam_scope constraints (#137) 2020-06-21 13:16:03 -04:00
Todd Knight 0a0d37668d Org List and Get API Methods (#132)
* Create the organization Get handler.

* Added org listing.

* Make sure the cmp.Diff always sorts the returned organizations before comparing.

* Connect organization service to the Controller handler.
2020-06-19 10:55:50 -07:00
Michael Gaffney 0ebb38bbe5 auth method schema (#131)
* Rename iam migrations to 06

* Add base tables for auth methods and auth accounts

* Add triggers for auth_method and auth_account subtypes
2020-06-19 13:10:05 -04:00
Jim ed60cac7fe add listing for groups and roles (#130) 2020-06-19 12:06:25 -04:00
Jim 1974e355c8 delete all users at the start of each test. (#129) 2020-06-19 11:27:35 -04:00
Jim c413e013bd get oplog Ticket before writing data (#127) 2020-06-18 21:24:55 -04:00
Jim 342bef7767 listing projects and organizations (#124) 2020-06-18 14:53:11 -04:00
Jim d9073a03d5 listing users (#118) 2020-06-16 18:59:30 -04:00
Todd Knight 6ea448a7f3 Adding Groups API endpoint and SDK (#122)
* feat: Add group grpc handler.

* feat: Add group sdk hooks.

* fix:  Adding forgotten generated group sdk file.

* fix:  Fix a copy/paste error in test msg.

* fix:  Correct assert error msg.

* fix: Remove unused proto imports.
2020-06-15 15:22:41 -07:00
Jim ffddf24f86 iam roles (#116) 2020-06-15 12:42:08 -04:00
Todd Knight 1637403624 fix: Removing unused imports and proto files. (#119) 2020-06-13 18:36:05 -07:00
Michael Gaffney 2d650b241d Fix down migrations (#120)
* Fix iam down migrations

* Fix '03_db' down migrations

* Fix oplog down migrations

* Fix domain down migrations

* Run make gen
2020-06-13 07:20:40 -04:00
Jim cc5114bdef refactor scopes to conform to public id usage and repo error msgs (#117) 2020-06-12 15:22:23 -04:00
Jim 5c2cff3ad2 iam groups (#112) 2020-06-11 16:36:47 -04:00
Michael Gaffney 4f30983c14 Bump deps and run make gen (#115) 2020-06-11 10:08:54 -04:00
Jeff Mitchell f41bf6e31e Add permission grant string parsing and validation and ACL implementation (#109)
This adds parsing and validation for grant strings along with the ability to create canonical JSON and text strings from a grant.

It also adds an ACL implementation, allowing a collection of grant strings to then be checked against a resource/action tuple and indicate if it's allowed.

Note that only specific sets of provided data in grant strings is allowed. This vastly simplifies logic.

Test coverage is 100%.

A future update will consolidate and migrate types between this and IAM but I didn't want to mix that in with this.
2020-06-10 17:58:52 -04:00
Jim 10e08e90f0 cleanup tests: properly use require, catch defer errors, use testing functions (#113) 2020-06-10 12:10:34 -04:00
Michael Gaffney ce166c0bdf Use dbassert package (#114)
Removes direct dependency on gorm in tests.
2020-06-10 09:06:41 -04:00
Jim Lambert 0a2e1c3946 minor changes to remove a line of dead code and update a comment 2020-06-10 07:03:51 -04:00
Jim 2d18177c9d oplog support for null field updates (#107) 2020-06-10 06:56:46 -04:00
Jim c70847fbac refactor delete test to be table driven. (#102) 2020-06-09 21:22:15 -04:00
Todd Knight df6ca5289f Create User Service Handler and SDK (#106)
* Create user handler stuff.

* Fixing Not Found errors from DB.

* Fixing param names.

* Update the proto's go package generation.

* Generate the user resource.

* Adding SDK methods for users.

* Fix the base type of Users and add tests.

* Connect user service to the controller handler.

* Attach the default org to the Test Controller's client.

* Take into account the provided request paths when the client builds the org/project path prefix.

* Adding comments to the API.

* rename repo function to repoFn.

* Fix typo in update mask errors.

* Clean up tests.

* Remove special checks for request url content in the api client and fix CORS test.
2020-06-09 11:20:59 -07:00
Todd Knight 2c3fbe3024 Invalid Argument errors provide per field details. (#110)
* Invalid Argument errors now return a per field error message.

* Creating an API error struct.

* SDK uses field error details proto.

* Adding tests specifically for handler helper error messages resulting in expected API output.

* Inlining the error checks into the table driven tests.  Use protocmp for assertions to make printing out diffs easier to parse.

* Aggregate the invalid argument fields detected to be wrong.

* Make the returned order of fields deterministic in the error details..

* Fixing formatting issue in errors_test.go.

* Test to confirm unimplemented results in a 405 and not 404.
2020-06-09 10:51:50 -07:00
Jeff Mitchell 5333482ff8 Fix gorm newlines issue (#108)
Even if you made a custom formatter for gorm, it would blithely println
anything returned, including nils, resulting in lots of new lines when
we were ignoring output. This also creates a custom logger that doesn't
do anything when newlines are found.
2020-06-08 21:12:00 -04:00
Todd Knight 6804c98b0b Applying Host Catalog comments to Projects (#105)
* NewService for the project service now returns a non pointer and an error.

* Replacing t.Fatal calls with require.NoError calls.

* Initialize empty slices following the recommended way.

* Don't inline the prefix strings when validating requests.

* Check error when cleaning up the test.

* Add check that update updates the time.

* Use google.golang.org/protobuf where possible instead of github.com/golang/protobuf.

* Shorten the validateX function names.

* Inline API responses.

* Change test cleanup error logging to t.Errorf.

* Remove unneeded creation of an extra project.

* Inline regex check for invalid id.

* Build the pb.Project inline when converting from db to wire proto.

* Change stored repos into repo creating functions.

* Using iam.TestScopes instead of creating them myself.

* Remove out of date comments.

* Update name to match go test naming standards.

* Adding project service comments.

* Using scopeType's new prefix method inside scope.go

* Setting test project's name and desc to default to pass tests.

* Change host catalog to project in test.

* Fixing merge errors.

* Fixing some more merge errors.

* Fix typo in comments.

* Fix typos in project_service.go.

* Update error indicating provided id and the expected prefix.

* Make the RepoFactory types in a common directory.
2020-06-08 14:43:13 -07:00
Jeff Malnick b016498d96 docs: update readme with quickstart section for local build (#104) 2020-06-08 14:20:25 -07:00
Todd Knight d374ac6d4c Handler hostcatalogs sdk (#103)
* Created host catalog service.

* Fixing uri generation for create.

* Use newly submitted static host catalog.

* Copying over tests from projects.

* Fix UpdateHostCatalogRequest merging proto.

* Properly use static host catalog prefixes in tests.

* Correct test to verify the expected uri and id prefix is set.

* Add test for unsetting descriptions.

* Correct bad spelling in comment.

* Tweaking variable names.

* Adding Stringer to the catalog type and setting the type on the response.

* Setting up the catalogType to contain more info regarding its type.

* Validate the type field in requests.

* Remove unused method.

* Comment describing invariants around types.

* Wiring in the repo into the static catalog handler.

* feature:  Add CRUD operations for host catalogs to the go api library.

* Updated comments to the exported methods.

* fix: return the result of handlers.NotFoundError instead of just calling it.

* Fixing typos referencing just hosts instead of host catlogs.

* Update NewService returns an error and a non pointer type.

* Pull "org_id" and "project_id" into constants and the validation of them into the ValidateAncestors.

* Check errors for all Register*HandlerServer calls.

* fix: Remove left over reference that could cause a panic.

* fix: Changing "x := []string{}" to "var x []string"

* fix: Log errors in test cleanup.

* Changing the code to use google.golang.org/protobuf instead of the older github based protobuf library.

* Changing all t.Fatal checks to require.NoError calls.

* Changing unrecognized prefixes to Invalid Argument instead of Not Found.

* fix: toDbUpdateMask now returns error if it was unable to find any valid paths.

* Define CreatedTime, UpdatedTime, and Type at initialization time in toProto.

* Adding sdk test for unsetting a value.

* Require that project is created correctly before testing the catalog.

* Remove unused host catalog from test.

* Change a t.Fatal to a require.NoError that I missed earlier.

* Change shutdown error logging to t.Errorfs.

* Shorten validateX function names.

* Inline API responses.

* Add todo to make a new repo per request.

* Inline regex check for invalid id.

* Change stored repos into repo creating functions which satisfies ICU-223.

* Wrap proto comments to be under 80 characters long.

* Remove the exception on the read only fields that can be set in an Update request.

* Removing out of date comment.

* Use iam.TestScopes instead of making the project myself.

* Renaming files to be consistant with go test standards and resource naming standards.

* Remove TODO related to a task completed in an earlier commit.

* Fix the previous commit which removed the wrong TODO.
2020-06-05 13:02:58 -07:00
Todd Knight 7f6e78e66e Handler hostcatalogs (#86)
* Created host catalog service.

* Fixing uri generation for create.

* Use newly submitted static host catalog.

* Copying over tests from projects.

* Fix UpdateHostCatalogRequest merging proto.

* Properly use static host catalog prefixes in tests.

* Correct test to verify the expected uri and id prefix is set.

* Add test for unsetting descriptions.

* Correct bad spelling in comment.

* Tweaking variable names.

* Adding Stringer to the catalog type and setting the type on the response.

* Setting up the catalogType to contain more info regarding its type.

* Validate the type field in requests.

* Remove unused method.

* Comment describing invariants around types.

* Wiring in the repo into the static catalog handler.

* Updated comments to the exported methods.

* fix: return the result of handlers.NotFoundError instead of just calling it.

* Fixing typos referencing just hosts instead of host catlogs.

* Update NewService returns an error and a non pointer type.

* Pull "org_id" and "project_id" into constants and the validation of them into the ValidateAncestors.

* Check errors for all Register*HandlerServer calls.

* fix: Remove left over reference that could cause a panic.

* fix: Changing "x := []string{}" to "var x []string"

* fix: Log errors in test cleanup.

* Changing the code to use google.golang.org/protobuf instead of the older github based protobuf library.

* Changing all t.Fatal checks to require.NoError calls.

* Changing unrecognized prefixes to Invalid Argument instead of Not Found.

* fix: toDbUpdateMask now returns error if it was unable to find any valid paths.

* Define CreatedTime, UpdatedTime, and Type at initialization time in toProto.

* Remove unused host catalog from test.

* Change a t.Fatal to a require.NoError that I missed earlier.

* Change shutdown error logging to t.Errorfs.

* Shorten validateX function names.

* Inline API responses.

* Add todo to make a new repo per request.

* Inline regex check for invalid id.

* Change stored repos into repo creating functions which satisfies ICU-223.

* Wrap proto comments to be under 80 characters long.

* Remove the exception on the read only fields that can be set in an Update request.

* Removing out of date comment.

* Use iam.TestScopes instead of making the project myself.

* Renaming files to be consistant with go test standards and resource naming standards.

* Remove TODO related to a task completed in an earlier commit.

* Fix the previous commit which removed the wrong TODO.
2020-06-05 11:52:59 -07:00
Jim 7d4993fb61 iam users (#96) 2020-06-04 20:05:08 -04:00
JimandJim Lambert e3fdb493b8 prevent primary key updates (#95)
* prevent primary key updates

* better error to return

Co-authored-by: Jim Lambert <jimlambrt@Jims-MBP-3.home>
2020-06-03 09:51:34 -04:00
Jim 1048673171 update dbassert dep (#100) 2020-06-02 12:07:00 -04:00
Jim 55be1f4931 Revert "updated dbassert dep (#98)" (#99)
This reverts commit 628f98d344.
2020-06-02 10:58:25 -04:00
Jim 628f98d344 updated dbassert dep (#98) 2020-06-02 10:16:56 -04:00
Jim 9feb280536 wrapper for dbasserts (#94) 2020-06-02 08:59:40 -04:00
Michael Gaffney cce06c2cc3 Do not explicitly call the embedded store.HostCatalog (#88) 2020-06-02 07:53:35 -04:00
Jeff Mitchell c175fcde8d Add a gorm log formatter to adapt to hclog (#93)
This is also added in a test that otherwise output to stdout, which
validates functionality.
2020-06-01 17:32:48 -04:00
Michael Gaffney 5bdd8a46ea Extract timestamp scanners into reusable package (#91)
* Refactor: move Timestamp from static/store to db/timestamp

* Refactor: convert remaining Timestamps to timestamp.Timestamp

* Use new db timestamp
2020-06-01 11:46:50 -04:00
Michael Gaffney 6a8fd56864 Fix after merging in #90 2020-06-01 10:27:49 -04:00
Michael Gaffney 9eaf8afb6f Rename db.IsUnique to db.IsUniqueError (#90) 2020-06-01 09:54:02 -04:00
Michael Gaffney 4f3f9ed222 Check for nil in embedded HostCatalog (#89) 2020-06-01 09:53:47 -04:00