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

Proof of concept on admin query interface #2120

Merged
merged 37 commits into from Jun 3, 2019
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
09805c5
exploratory work for query interace
mikena-truss May 8, 2019
9c9e115
Merge branch 'master' into mw-add-query-interface
mikena-truss May 9, 2019
f35a400
add list fetcher
mikena-truss May 10, 2019
fafc674
move DB tests to builder
mikena-truss May 10, 2019
0bc888e
checkpoint before messing with interface pointer
mikena-truss May 10, 2019
df3aca3
remove unused mock
mikena-truss May 10, 2019
64d6b1f
add tests for office user fetcher
mikena-truss May 10, 2019
f4d47a8
add list tests
mikena-truss May 10, 2019
5d15e49
fix some linting mistakes
mikena-truss May 10, 2019
a660c46
office user fetcher lint fixes
mikena-truss May 10, 2019
b312abb
Merge branch 'master' into mw-add-query-interface
mikena-truss May 20, 2019
82e8673
Merge branch 'master' into mw-add-query-interface
mikena-truss May 21, 2019
5450a94
add type checking for reflection
mikena-truss May 21, 2019
ebaecda
write tests for type checks
mikena-truss May 21, 2019
ceed57a
user same pattern for FetchOne as FetchMany
mikena-truss May 22, 2019
abdddaa
comments + test fixes
mikena-truss May 22, 2019
985f04a
fix office user fetcher to conform to FetchOne
mikena-truss May 22, 2019
cd6aa19
first pass at adding filters
mikena-truss May 22, 2019
0cb9775
Merge branch 'master' into mw-add-query-interface
mikena-truss May 24, 2019
2e4b0a1
refactor query filter to use interface pattern in service layer
mikena-truss May 24, 2019
953823f
remove custom error type for now
mikena-truss May 24, 2019
7556621
test for invalid comparators
mikena-truss May 24, 2019
84afdda
pass the services into the handler
mikena-truss May 24, 2019
c9c3780
change PopQueryBuilder to QueryBuilder
mikena-truss May 24, 2019
a3e8729
return a pointer in query builder constructor
mikena-truss May 24, 2019
bda112b
add integration test
mikena-truss May 24, 2019
c10a1bc
add handler unit test with mock
mikena-truss May 24, 2019
168b67a
add test for error
mikena-truss May 24, 2019
d48cd88
convert value to an interface{} so db connector can get underlying type
mikena-truss May 28, 2019
9aa2c93
Merge branch 'master' into mw-add-query-interface
mikena-truss May 31, 2019
82478c8
continue over bad columns
mikena-truss May 31, 2019
a6b89a9
Merge branch 'master' into mw-add-query-interface
mikena-truss May 31, 2019
faa56cd
fix filters typo
mikena-truss May 31, 2019
82fc0a8
Merge branch 'master' into mw-add-query-interface
mikena-truss Jun 3, 2019
ea531e8
replace reflection error with constant
mikena-truss Jun 3, 2019
de65d2d
add link to OWASP guidelines
mikena-truss Jun 3, 2019
8142d6e
grammer updates
mikena-truss Jun 3, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

office user fetcher lint fixes

  • Loading branch information...
mikena-truss committed May 10, 2019
commit a660c4637abc322dd2106f3d408c5ff19c145476
@@ -13,12 +13,14 @@ type officeUserFetcher struct {
builder officeUserQueryBuilder
}

// FetchOfficeUser fetches an office user for the given field/value pair
func (o officeUserFetcher) FetchOfficeUser(field string, value interface{}) (models.OfficeUser, error) {

This comment has been minimized.

Copy link
@mikena-truss

mikena-truss May 10, 2019

Author Contributor

This methods becomes pretty light. In the future more will happen here. Like more advanced querying or authorization patterns.

This comment has been minimized.

Copy link
@jim

jim May 16, 2019

Contributor

We could use code generation to generate model-specific funcs that return a specific type. This would get us away from passing in a pointer to work around the type system.

var officeUser models.OfficeUser
error := o.builder.FetchOne(&officeUser, field, value)

This comment has been minimized.

Copy link
@mikena-truss

mikena-truss May 10, 2019

Author Contributor

Notice that the FetchOne doesn't return the office user. This is similar to how pop does things (modifying the pointer). The reason being, with reflection, you would have to return interface{} and then typecast it (I think).

This comment has been minimized.

Copy link
@macrael

macrael May 15, 2019

Contributor

That's right, and I like that this function does return a model, that way we keep the reflection stuff contained a bit.

return officeUser, error
}

// NewOfficeUserFetcher return an implementaion of the OfficeUserFetcher interface
func NewOfficeUserFetcher(builder officeUserQueryBuilder) services.OfficeUserFetcher {
return officeUserFetcher{builder}
}
@@ -13,12 +13,14 @@ type officeUserListFetcher struct {
builder officeUserListQueryBuilder
}

// FetchOfficeUserList is uses the passed query builder to fetch a list of office users
func (o officeUserListFetcher) FetchOfficeUserList(filters map[string]interface{}) (models.OfficeUsers, error) {
var officeUsers models.OfficeUsers
error := o.builder.FetchMany(&officeUsers, filters)
return officeUsers, error
}

// NewOfficeUserListFetcher returns an implementation of OfficeUserListFetcher
func NewOfficeUserListFetcher(builder officeUserListQueryBuilder) services.OfficeUserListFetcher {
return officeUserListFetcher{builder}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.