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

fix(loginresultparams): export all fields such that login provider im… #17372

Open
wants to merge 1 commit into
base: 3.5
Choose a base branch
from

Conversation

ale8k
Copy link

@ale8k ale8k commented May 14, 2024

Due to a mistake in the initial implementation of LoginProviders, the fields were left unexported. This disallows the capability of creating your own LoginProvider to Juju. The specific case here is a JWT login provider which is specific to JIMM and as such we wish to implement the provider in JIMM.

Checklist

  • Code style: imports ordered, good names, simple structure, etc
  • Comments saying why design decisions were made
  • Go unit tests, with comments saying what you're testing
  • Integration tests, with comments saying what you're testing
  • doc.go added or updated in changed packages

QA steps

Documentation changes

Links

Launchpad bug: https://bugs.launchpad.net/juju/+bug/

Jira card: JUJU-

@wallyworld
Copy link
Member

/build

@ale8k ale8k force-pushed the export-fields-on-login-result-params branch from b4f9cf9 to 3cb4ab4 Compare May 15, 2024 08:26
Due to a mistake in the initial implementation of LoginProviders, the fields were left unexported. This disallows the capability of creating your own LoginProvider to Juju. The specific case here is a JWT login provider which is specific to JIMM and as such we wish to implement the provider in JIMM.
@ale8k ale8k force-pushed the export-fields-on-login-result-params branch from 3cb4ab4 to 62a32d5 Compare May 15, 2024 08:37
Copy link
Member

@wallyworld wallyworld left a comment

Choose a reason for hiding this comment

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

I'm surprised there was no test fallout. That implies we have insufficient unit test coverage for these login providers. In fact, this code


func (s *tryInOrderLoginProviderSuite) Test(c *gc.C) {
	p1 := &mockLoginProvider{err: errors.New("provider 1 error")}
	p2 := &mockLoginProvider{err: errors.New("provider 2 error")}
	p3 := &mockLoginProvider{}

	lp := api.NewTryInOrderLoginProvider(p1, p2)
	_, err := lp.Login(context.Background(), nil)
	c.Assert(err, gc.ErrorMatches, "provider 2 error")

	lp = api.NewTryInOrderLoginProvider(p1, p2, p3)
	_, err = lp.Login(context.Background(), nil)
	c.Assert(err, jc.ErrorIsNil)
}

type mockLoginProvider struct {
	err error
}

func (p *mockLoginProvider) Login(ctx context.Context, caller base.APICaller) (*api.LoginResultParams, error) {
	return &api.LoginResultParams{}, p.err
}

should be updated to improve the test. Specifically this bit


	_, err = lp.Login(context.Background(), nil)
	c.Assert(err, jc.ErrorIsNil)
	
	```
should  test the returned value for a populated result struct.

@hpidcock hpidcock added the 3.5 label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants