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

NET-260 REST API tests #2351

Closed
wants to merge 25 commits into from
Closed

NET-260 REST API tests #2351

wants to merge 25 commits into from

Conversation

TobiaszCudnik
Copy link
Contributor

@TobiaszCudnik TobiaszCudnik commented May 29, 2023

Describe your changes

NET-260 REST API tests for GET /api/v1/enrollment-keys.

Provide testing steps

go test ./... -v -tags integration -test.run TestHasNetworksAccessAPI

Checklist before requesting a review

  • My changes affect only 10 files or less.
  • I have performed a self-review of my code and tested it.
  • If it is a new feature, I have added thorough tests, my code is <= 1450 lines.
  • If it is a bugfix, my code is <= 200 lines.
  • My functions are <= 80 lines.
  • I have had my code reviewed by a peer.
  • My unit tests pass locally.
  • Netmaker is awesome.

- return hosts with partial access
…st-api-tests

# Conflicts:
#	controllers/enrollmentkeys.go
Copy link
Contributor

@mattkasun mattkasun left a comment

Choose a reason for hiding this comment

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

fix order of imports in database/sqlite.go

@@ -3,14 +3,23 @@ package database
import (
"database/sql"
"errors"
_ "github.com/mattn/go-sqlite3" // need to blank import this package
Copy link
Contributor

Choose a reason for hiding this comment

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

did you run go fmt and/or go import. stdlib imports should be listed first followed by external lib imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

goimports should be added to precommit. gofmt orders it differently.

@TobiaszCudnik TobiaszCudnik requested a review from mattkasun May 30, 2023 12:03
Copy link
Contributor

@theguy951357 theguy951357 left a comment

Choose a reason for hiding this comment

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

kitemake ticket is listed in on hold column so I didn't move it, but pr steps pass and critical list passes.

@TobiaszCudnik
Copy link
Contributor Author

kitemake ticket is listed in on hold column so I didn't move it, but pr steps pass and critical list passes.

@theguy951357 It's not a user facing feature / release-bound code, so it doesnt have to be QA-ed. Thanks anyway!

@TobiaszCudnik TobiaszCudnik changed the base branch from NET-152/enrollment-keys-for-non-admins to develop May 31, 2023 09:08
Copy link
Contributor

@gabrielseibel1 gabrielseibel1 left a comment

Choose a reason for hiding this comment

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

assertion for last test?

}
err = logic.CreateUser(user)
if err != nil {
t.Error("Error creating a user ", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

could use t.Fatal here?

adminConfigBad.MasterKey = "wrongpass"
adminConfigBad.Password = "wrongpass"
// add configs
config.SetContext("user-ctx-1", userConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

the context names could be extracted as variables/consts maybe, to avoid writing it wrong and facing a difficult to debug situation

keys := *functions.GetEnrollmentKeys()
assert.Len(t, keys, 1, "1 key expected")
assert.Len(t, keys[0].Networks, 1, "Key with 1 network expected")
assert.Equal(t, keys[0].Networks[0], n1.NetID, "Network ID matches")
Copy link
Contributor

Choose a reason for hiding this comment

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

are these messages not displayed on failure? honestly thought that but am not sure

// TODO doesnt return err
res := *functions.GetEnrollmentKeys()
fmt.Println(res)
//assert.Error(t, res, "403 error")
Copy link
Contributor

Choose a reason for hiding this comment

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

should probably have an assertion here, len 0?

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.

6 participants