AuthN: Make client params part of the identity (#61050)

* AuthN: Change client params to be a return value of authenticate

* AuthN: move client params to be part of the identity
This commit is contained in:
Karl Persson
2023-01-05 20:17:41 +01:00
committed by GitHub
parent 183397194a
commit cdd7392f68
14 changed files with 91 additions and 128 deletions
@@ -85,9 +85,8 @@ func TestUserSync_SyncUser(t *testing.T) {
log log.Logger
}
type args struct {
ctx context.Context
clientParams *authn.ClientParams
id *authn.Identity
ctx context.Context
id *authn.Identity
}
tests := []struct {
name string
@@ -106,11 +105,6 @@ func TestUserSync_SyncUser(t *testing.T) {
},
args: args{
ctx: context.Background(),
clientParams: &authn.ClientParams{
SyncUser: false,
AllowSignUp: false,
EnableDisabledUsers: false,
},
id: &authn.Identity{
ID: "",
Login: "test",
@@ -121,6 +115,7 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: ptrString("test"),
Login: nil,
},
ClientParams: authn.ClientParams{},
},
},
wantErr: false,
@@ -134,6 +129,7 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: ptrString("test"),
Login: nil,
},
ClientParams: authn.ClientParams{},
},
},
{
@@ -146,11 +142,6 @@ func TestUserSync_SyncUser(t *testing.T) {
},
args: args{
ctx: context.Background(),
clientParams: &authn.ClientParams{
SyncUser: true,
AllowSignUp: false,
EnableDisabledUsers: false,
},
id: &authn.Identity{
ID: "",
Login: "test",
@@ -161,6 +152,9 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: ptrString("test"),
Login: nil,
},
ClientParams: authn.ClientParams{
SyncUser: true,
},
},
},
wantErr: false,
@@ -175,6 +169,9 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: ptrString("test"),
Login: nil,
},
ClientParams: authn.ClientParams{
SyncUser: true,
},
},
},
{
@@ -187,11 +184,6 @@ func TestUserSync_SyncUser(t *testing.T) {
},
args: args{
ctx: context.Background(),
clientParams: &authn.ClientParams{
SyncUser: true,
AllowSignUp: false,
EnableDisabledUsers: false,
},
id: &authn.Identity{
ID: "",
Login: "test",
@@ -202,6 +194,9 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: nil,
Login: ptrString("test"),
},
ClientParams: authn.ClientParams{
SyncUser: true,
},
},
},
wantErr: false,
@@ -216,6 +211,9 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: nil,
Login: ptrString("test"),
},
ClientParams: authn.ClientParams{
SyncUser: true,
},
},
},
{
@@ -228,11 +226,6 @@ func TestUserSync_SyncUser(t *testing.T) {
},
args: args{
ctx: context.Background(),
clientParams: &authn.ClientParams{
SyncUser: true,
AllowSignUp: false,
EnableDisabledUsers: false,
},
id: &authn.Identity{
ID: "",
Login: "test",
@@ -243,6 +236,9 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: nil,
Login: nil,
},
ClientParams: authn.ClientParams{
SyncUser: true,
},
},
},
wantErr: false,
@@ -257,6 +253,9 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: nil,
Login: nil,
},
ClientParams: authn.ClientParams{
SyncUser: true,
},
},
},
{
@@ -269,11 +268,7 @@ func TestUserSync_SyncUser(t *testing.T) {
},
args: args{
ctx: context.Background(),
clientParams: &authn.ClientParams{
SyncUser: true,
AllowSignUp: false,
EnableDisabledUsers: false,
},
id: &authn.Identity{
ID: "",
Login: "test",
@@ -284,6 +279,9 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: nil,
Login: nil,
},
ClientParams: authn.ClientParams{
SyncUser: true,
},
},
},
wantErr: false,
@@ -298,6 +296,9 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: nil,
Login: nil,
},
ClientParams: authn.ClientParams{
SyncUser: true,
},
},
},
{
@@ -310,11 +311,6 @@ func TestUserSync_SyncUser(t *testing.T) {
},
args: args{
ctx: context.Background(),
clientParams: &authn.ClientParams{
SyncUser: true,
AllowSignUp: false,
EnableDisabledUsers: false,
},
id: &authn.Identity{
ID: "",
Login: "test",
@@ -327,6 +323,9 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: nil,
Login: nil,
},
ClientParams: authn.ClientParams{
SyncUser: true,
},
},
},
wantErr: true,
@@ -341,11 +340,6 @@ func TestUserSync_SyncUser(t *testing.T) {
},
args: args{
ctx: context.Background(),
clientParams: &authn.ClientParams{
SyncUser: true,
AllowSignUp: true,
EnableDisabledUsers: true,
},
id: &authn.Identity{
ID: "",
Login: "test_create",
@@ -359,6 +353,11 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: ptrString("test_create"),
Login: nil,
},
ClientParams: authn.ClientParams{
SyncUser: true,
AllowSignUp: true,
EnableDisabledUsers: true,
},
},
},
wantErr: false,
@@ -375,6 +374,11 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: ptrString("test_create"),
Login: nil,
},
ClientParams: authn.ClientParams{
SyncUser: true,
AllowSignUp: true,
EnableDisabledUsers: true,
},
},
},
{
@@ -387,11 +391,6 @@ func TestUserSync_SyncUser(t *testing.T) {
},
args: args{
ctx: context.Background(),
clientParams: &authn.ClientParams{
SyncUser: true,
AllowSignUp: false,
EnableDisabledUsers: true,
},
id: &authn.Identity{
ID: "",
Login: "test_mod",
@@ -404,6 +403,10 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: nil,
Login: nil,
},
ClientParams: authn.ClientParams{
SyncUser: true,
EnableDisabledUsers: true,
},
},
},
wantErr: false,
@@ -419,6 +422,10 @@ func TestUserSync_SyncUser(t *testing.T) {
Email: nil,
Login: nil,
},
ClientParams: authn.ClientParams{
SyncUser: true,
EnableDisabledUsers: true,
},
},
},
}
@@ -430,7 +437,7 @@ func TestUserSync_SyncUser(t *testing.T) {
quotaService: tt.fields.quotaService,
log: tt.fields.log,
}
err := s.SyncUser(tt.args.ctx, tt.args.clientParams, tt.args.id, nil)
err := s.SyncUser(tt.args.ctx, tt.args.id, nil)
if tt.wantErr {
require.Error(t, err)
return