Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

[Tests-Only] Add tests for gRPC #32

Merged
merged 1 commit into from
Jul 21, 2020
Merged

[Tests-Only] Add tests for gRPC #32

merged 1 commit into from
Jul 21, 2020

Conversation

dpakach
Copy link
Contributor

@dpakach dpakach commented May 13, 2020

Add gRPC integration tests for accounts and group related actions for

  • CreateAccount
  • ListAccounts
  • GetAccount
  • UpdateAccount
  • DeleteAccount
  • ListGroup
  • AddGroup
  • DeleteGroup
  • GetGroup
  • UpdateGroup(not implemented)
  • AddMember
  • ListMembers
  • RemoveMembers

fixes #29

@individual-it
Copy link
Member

vet step failed for some reason :(
image

@dpakach
Copy link
Contributor Author

dpakach commented May 13, 2020

vet step failed for some reason :(
image

Yes seems like somethings changed here, when I rebased it's not working now, I'll fix and push again.

@dpakach dpakach force-pushed the grpc-tests branch 4 times, most recently from 11f3373 to 64dcdb1 Compare May 13, 2020 09:30
@dpakach
Copy link
Contributor Author

dpakach commented May 22, 2020

Looks like #30 changes a lot of APIs so waiting for that to get merged before proceeding with it.

@refs
Copy link
Member

refs commented May 22, 2020

@dpakach indeed. I flagged #30 as blocked because of what you mentioned, it drastically changes the API and #22 will be merged first, then we will build on top of it for #30.

@individual-it individual-it added blocked MUST be merged after the blocking PR QA-team labels May 25, 2020
@butonic
Copy link
Member

butonic commented Jul 10, 2020

@dpakach we merged the initial group support. only updating groups is not yet covered. but tha api has settled for now.

@dpakach dpakach self-assigned this Jul 15, 2020
@dpakach dpakach force-pushed the grpc-tests branch 2 times, most recently from 9010e62 to 0e6ca8c Compare July 17, 2020 06:01
@dpakach dpakach marked this pull request as ready for review July 17, 2020 06:02
Copy link
Member

@individual-it individual-it left a comment

Choose a reason for hiding this comment

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

looks pretty good so far 🚀

some lines are pretty long, please make them shorter

please raise issues about the found bugs and mark the tests, so they point to the issues see https://github.com/owncloud/ocis-settings/pull/21/files#diff-477228b861253bdc0920482b86df104fR124

assertResponseContainsUser(t, resp, getAccount("user1"))
assertResponseContainsUser(t, resp, getAccount("user2"))

// time.Sleep(time.Second * 30)
Copy link
Member

Choose a reason for hiding this comment

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

debug line?


// time.Sleep(time.Second * 30)

fmt.Println("new Users", newCreatedAccounts)
Copy link
Member

Choose a reason for hiding this comment

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

debug line? can it be deleted?

assert.IsType(t, &proto.Group{}, resp)
assert.Empty(t, resp)
assert.Error(t, err)
assert.Equal(t, "{\"id\":\".\",\"code\":404,\"detail\":\"could not read group: open accounts-store/groups/42: no such file or directory\",\"status\":\"Not Found\"}", err.Error())
Copy link
Member

Choose a reason for hiding this comment

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

can we unmarshal this string and compare the JSON object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The server returns this as a string so I don't think that will be really necessary

func TestDeleteGroup(t *testing.T) {
grp1 := getTestGroups("grp1")
grp2 := getTestGroups("grp2")
// grp3 := getTestGroups("grp3")
Copy link
Member

Choose a reason for hiding this comment

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

what happened to grp3?

@dpakach dpakach removed the blocked MUST be merged after the blocking PR label Jul 20, 2020
@dpakach dpakach requested a review from individual-it July 20, 2020 06:06

resp := listGroups(t)
assertResponseContainsGroup(t, resp, updatedGroup)

Copy link
Member

Choose a reason for hiding this comment

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

need to check if member was added

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the updatedGroups contains the new member too. if the response contains the updated group then I think we can safely assume that them member was added.

// assertGroupsSame(t, grp1, res)

resp := listGroups(t)
assertResponseContainsGroup(t, resp, grp1)
Copy link
Member

Choose a reason for hiding this comment

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

need also to check that the member is not in the group anymore

Copy link
Contributor Author

@dpakach dpakach Jul 20, 2020

Choose a reason for hiding this comment

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

The original grp1 doesn't contain the member, in the beginning. If the response contains grp1, then we can assume that the member was removed from the group successfully.

func assertResponseNotContainsUser(t *testing.T, response *proto.ListAccountsResponse, account *proto.Account) {
for _, a := range response.Accounts {
if a.Id == account.Id || a.PreferredName == account.PreferredName {
t.Fatal("Account not found in response")
Copy link
Contributor

Choose a reason for hiding this comment

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

account found or not found?

@jasson99 jasson99 self-requested a review July 20, 2020 07:32
func assertResponseNotContainsGroup(t *testing.T, response *proto.ListGroupsResponse, group *proto.Group) {
for _, g := range response.Groups {
if g.Id == group.Id && g.DisplayName == group.DisplayName {
t.Fatal("Group not found in response")
Copy link
Contributor

Choose a reason for hiding this comment

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

Group found or not found?

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@individual-it individual-it merged commit 7af05fb into master Jul 21, 2020
@delete-merged-branch delete-merged-branch bot deleted the grpc-tests branch July 21, 2020 03:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

write GRPC tests
5 participants