-
Notifications
You must be signed in to change notification settings - Fork 1
Add endpoint oidc email to enroll response #29
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ee1ad14
Add endpoint oidc email to enroll response
IanVS 2776d9e
Add endpoint oidc email to doUpdate response
IanVS abf08ef
Make existing tests pass
IanVS df3f360
Assert happy-path values
IanVS 593d2a0
Check what happens when email is nil
IanVS cad71bc
Fix nil location
IanVS 42bd453
Remove omitempty
IanVS e6d8fad
Little more test cleanup
IanVS 2265297
Assert nil on standard host
IanVS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,7 @@ func TestEnroll(t *testing.T) { | |
| hostID := "foobar" | ||
| hostName := "foo host" | ||
| hostIP := "192.168.100.1" | ||
| oidcEmail := "[email protected]" | ||
| counter := uint(5) | ||
| ca, _ := dnapitest.NebulaCACert() | ||
| caPEM, err := ca.MarshalToPEM() | ||
|
|
@@ -92,6 +93,9 @@ func TestEnroll(t *testing.T) { | |
| Name: hostName, | ||
| IPAddress: hostIP, | ||
| }, | ||
| EndpointOIDCMeta: &message.HostEndpointOIDCMetadata{ | ||
| Email: oidcEmail, | ||
| }, | ||
| }, | ||
| }) | ||
| }) | ||
|
|
@@ -139,6 +143,7 @@ func TestEnroll(t *testing.T) { | |
| assert.Equal(t, hostID, meta.Host.ID) | ||
| assert.Equal(t, hostName, meta.Host.Name) | ||
| assert.Equal(t, hostIP, meta.Host.IPAddress) | ||
| assert.Equal(t, oidcEmail, meta.EndpointOIDC.Email) | ||
|
|
||
| // Test error handling | ||
| errorMsg := "invalid enrollment code" | ||
|
|
@@ -377,6 +382,7 @@ func TestDoUpdate(t *testing.T) { | |
| hostID := "foobar" | ||
| hostName := "foo host" | ||
| hostIP := "192.168.100.1" | ||
| oidcEmail := "[email protected]" | ||
|
|
||
| // This time sign the response with the correct CA key. | ||
| ts.ExpectDNClientRequest(message.DoUpdate, http.StatusOK, func(r message.RequestWrapper) []byte { | ||
|
|
@@ -400,6 +406,9 @@ func TestDoUpdate(t *testing.T) { | |
| Name: hostName, | ||
| IPAddress: hostIP, | ||
| }, | ||
| EndpointOIDCMeta: &message.HostEndpointOIDCMetadata{ | ||
| Email: oidcEmail, | ||
| }, | ||
| } | ||
| rawRes := jsonMarshal(newConfigResponse) | ||
|
|
||
|
|
@@ -427,6 +436,7 @@ func TestDoUpdate(t *testing.T) { | |
| assert.Equal(t, hostID, meta.Host.ID) | ||
| assert.Equal(t, hostName, meta.Host.Name) | ||
| assert.Equal(t, hostIP, meta.Host.IPAddress) | ||
| assert.Equal(t, oidcEmail, meta.EndpointOIDC.Email) | ||
|
|
||
| } | ||
|
|
||
|
|
@@ -727,7 +737,7 @@ func TestCommandResponse(t *testing.T) { | |
|
|
||
| ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) | ||
| defer cancel() | ||
| config, pkey, creds, _, err := c.Enroll(ctx, testutil.NewTestLogger(), "foobar") | ||
| config, pkey, creds, meta, err := c.Enroll(ctx, testutil.NewTestLogger(), "foobar") | ||
| require.NoError(t, err) | ||
|
|
||
| // make sure all credential values were set | ||
|
|
@@ -740,6 +750,9 @@ func TestCommandResponse(t *testing.T) { | |
| assert.NotEmpty(t, config) | ||
| assert.NotEmpty(t, pkey) | ||
|
|
||
| // no EndpointOIDC for standard host enrollments | ||
| assert.Nil(t, meta.EndpointOIDC) | ||
|
|
||
| // This time sign the response with the correct CA key. | ||
| responseToken := "abc123" | ||
| res := map[string]any{"msg": "Hello, world!"} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for completeness sake, you could add a
assert.Nil(t, meta.EndpointOIDC)to an existing test. dubious value maybe