2021-03-15 11:51:15 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-04-05 09:35:49 +00:00
|
|
|
"io"
|
2021-03-19 17:46:26 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2024-04-05 09:35:49 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/zitadel/passwap"
|
|
|
|
"github.com/zitadel/passwap/bcrypt"
|
2021-03-19 17:46:26 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/command/preparation"
|
|
|
|
"github.com/zitadel/zitadel/internal/crypto"
|
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
|
|
|
"github.com/zitadel/zitadel/internal/id"
|
|
|
|
id_mock "github.com/zitadel/zitadel/internal/id/mock"
|
|
|
|
"github.com/zitadel/zitadel/internal/repository/project"
|
2023-12-08 14:30:55 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
2021-03-15 11:51:15 +00:00
|
|
|
)
|
|
|
|
|
2022-04-12 14:20:17 +00:00
|
|
|
func TestAddOIDCApp(t *testing.T) {
|
feat: Configurable Unique Machine Identification (#3626)
* feat: Configurable Unique Machine Identification
This change fixes Segfault on AWS App Runner with v2 #3625
The change introduces two new dependencies:
* github.com/drone/envsubst for supporting AWS ECS, which has its metadata endpoint described by an environment variable
* github.com/jarcoal/jpath so that only relevant data from a metadata response is used to identify the machine.
The change ads new configuration (see `defaults.yaml`):
* `Machine.Identification` enables configuration of how machines are uniquely identified - I'm not sure about the top level category `Machine`, as I don't have anything else to add to it. Happy to hear suggestions for better naming or structure here.
* `Machine.Identifiation.PrivateId` turns on or off the existing private IP based identification. Default is on.
* `Machine.Identification.Hostname` turns on or off using the OS hostname to identify the machine. Great for most cloud environments, where this tends to be set to something that identifies the machine uniquely. Enabled by default.
* `Machine.Identification.Webhook` configures identification based on the response to an HTTP GET request. Request headers can be configured, a JSONPath can be set for processing the response (no JSON parsing is done if this is not set), and the URL is allowed to contain environment variables in the format `"${var}"`.
The new flow for getting a unique machine id is:
1. PrivateIP (if enabled)
2. Hostname (if enabled)
3. Webhook (if enabled, to configured URL)
4. Give up and error out.
It's important that init configures machine identity first. Otherwise we could try to get an ID before configuring it. To prevent this from causing difficult to debug issues, where for example the default configuration was used, I've ensured that
the application will generate an error if the module hasn't been configured and you try to get an ID.
Misc changes:
* Spelling and gramatical corrections to `init.go::New()` long description.
* Spelling corrections to `verify_zitadel.go::newZitadel()`.
* Updated `production.md` and `development.md` based on the new build process. I think the run instructions are also out of date, but I'll leave that for someone else.
* `id.SonyFlakeGenerator` is now a function, which sets `id.sonyFlakeGenerator`, this allows us to defer initialization until configuration has been read.
* Update internal/id/config.go
Co-authored-by: Alexei-Barnes <82444470+Alexei-Barnes@users.noreply.github.com>
* Fix authored by @livio-a for tests
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-05-24 14:57:57 +00:00
|
|
|
type fields struct {
|
|
|
|
idGenerator id.Generator
|
|
|
|
}
|
2022-04-12 14:20:17 +00:00
|
|
|
type args struct {
|
2024-04-05 09:35:49 +00:00
|
|
|
app *addOIDCApp
|
|
|
|
filter preparation.FilterToQueryReducer
|
2022-04-12 14:20:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
agg := project.NewAggregate("test", "test")
|
|
|
|
|
|
|
|
tests := []struct {
|
feat: Configurable Unique Machine Identification (#3626)
* feat: Configurable Unique Machine Identification
This change fixes Segfault on AWS App Runner with v2 #3625
The change introduces two new dependencies:
* github.com/drone/envsubst for supporting AWS ECS, which has its metadata endpoint described by an environment variable
* github.com/jarcoal/jpath so that only relevant data from a metadata response is used to identify the machine.
The change ads new configuration (see `defaults.yaml`):
* `Machine.Identification` enables configuration of how machines are uniquely identified - I'm not sure about the top level category `Machine`, as I don't have anything else to add to it. Happy to hear suggestions for better naming or structure here.
* `Machine.Identifiation.PrivateId` turns on or off the existing private IP based identification. Default is on.
* `Machine.Identification.Hostname` turns on or off using the OS hostname to identify the machine. Great for most cloud environments, where this tends to be set to something that identifies the machine uniquely. Enabled by default.
* `Machine.Identification.Webhook` configures identification based on the response to an HTTP GET request. Request headers can be configured, a JSONPath can be set for processing the response (no JSON parsing is done if this is not set), and the URL is allowed to contain environment variables in the format `"${var}"`.
The new flow for getting a unique machine id is:
1. PrivateIP (if enabled)
2. Hostname (if enabled)
3. Webhook (if enabled, to configured URL)
4. Give up and error out.
It's important that init configures machine identity first. Otherwise we could try to get an ID before configuring it. To prevent this from causing difficult to debug issues, where for example the default configuration was used, I've ensured that
the application will generate an error if the module hasn't been configured and you try to get an ID.
Misc changes:
* Spelling and gramatical corrections to `init.go::New()` long description.
* Spelling corrections to `verify_zitadel.go::newZitadel()`.
* Updated `production.md` and `development.md` based on the new build process. I think the run instructions are also out of date, but I'll leave that for someone else.
* `id.SonyFlakeGenerator` is now a function, which sets `id.sonyFlakeGenerator`, this allows us to defer initialization until configuration has been read.
* Update internal/id/config.go
Co-authored-by: Alexei-Barnes <82444470+Alexei-Barnes@users.noreply.github.com>
* Fix authored by @livio-a for tests
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-05-24 14:57:57 +00:00
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
args args
|
|
|
|
want Want
|
2022-04-12 14:20:17 +00:00
|
|
|
}{
|
|
|
|
{
|
feat: Configurable Unique Machine Identification (#3626)
* feat: Configurable Unique Machine Identification
This change fixes Segfault on AWS App Runner with v2 #3625
The change introduces two new dependencies:
* github.com/drone/envsubst for supporting AWS ECS, which has its metadata endpoint described by an environment variable
* github.com/jarcoal/jpath so that only relevant data from a metadata response is used to identify the machine.
The change ads new configuration (see `defaults.yaml`):
* `Machine.Identification` enables configuration of how machines are uniquely identified - I'm not sure about the top level category `Machine`, as I don't have anything else to add to it. Happy to hear suggestions for better naming or structure here.
* `Machine.Identifiation.PrivateId` turns on or off the existing private IP based identification. Default is on.
* `Machine.Identification.Hostname` turns on or off using the OS hostname to identify the machine. Great for most cloud environments, where this tends to be set to something that identifies the machine uniquely. Enabled by default.
* `Machine.Identification.Webhook` configures identification based on the response to an HTTP GET request. Request headers can be configured, a JSONPath can be set for processing the response (no JSON parsing is done if this is not set), and the URL is allowed to contain environment variables in the format `"${var}"`.
The new flow for getting a unique machine id is:
1. PrivateIP (if enabled)
2. Hostname (if enabled)
3. Webhook (if enabled, to configured URL)
4. Give up and error out.
It's important that init configures machine identity first. Otherwise we could try to get an ID before configuring it. To prevent this from causing difficult to debug issues, where for example the default configuration was used, I've ensured that
the application will generate an error if the module hasn't been configured and you try to get an ID.
Misc changes:
* Spelling and gramatical corrections to `init.go::New()` long description.
* Spelling corrections to `verify_zitadel.go::newZitadel()`.
* Updated `production.md` and `development.md` based on the new build process. I think the run instructions are also out of date, but I'll leave that for someone else.
* `id.SonyFlakeGenerator` is now a function, which sets `id.sonyFlakeGenerator`, this allows us to defer initialization until configuration has been read.
* Update internal/id/config.go
Co-authored-by: Alexei-Barnes <82444470+Alexei-Barnes@users.noreply.github.com>
* Fix authored by @livio-a for tests
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-05-24 14:57:57 +00:00
|
|
|
name: "invalid appID",
|
|
|
|
fields: fields{},
|
2022-04-12 14:20:17 +00:00
|
|
|
args: args{
|
|
|
|
app: &addOIDCApp{
|
|
|
|
AddApp: AddApp{
|
|
|
|
Aggregate: *agg,
|
|
|
|
ID: "",
|
|
|
|
Name: "name",
|
|
|
|
},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
Version: domain.OIDCVersionV1,
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
want: Want{
|
2023-12-08 14:30:55 +00:00
|
|
|
ValidationErr: zerrors.ThrowInvalidArgument(nil, "PROJE-NnavI", "Errors.Invalid.Argument"),
|
2022-04-12 14:20:17 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
feat: Configurable Unique Machine Identification (#3626)
* feat: Configurable Unique Machine Identification
This change fixes Segfault on AWS App Runner with v2 #3625
The change introduces two new dependencies:
* github.com/drone/envsubst for supporting AWS ECS, which has its metadata endpoint described by an environment variable
* github.com/jarcoal/jpath so that only relevant data from a metadata response is used to identify the machine.
The change ads new configuration (see `defaults.yaml`):
* `Machine.Identification` enables configuration of how machines are uniquely identified - I'm not sure about the top level category `Machine`, as I don't have anything else to add to it. Happy to hear suggestions for better naming or structure here.
* `Machine.Identifiation.PrivateId` turns on or off the existing private IP based identification. Default is on.
* `Machine.Identification.Hostname` turns on or off using the OS hostname to identify the machine. Great for most cloud environments, where this tends to be set to something that identifies the machine uniquely. Enabled by default.
* `Machine.Identification.Webhook` configures identification based on the response to an HTTP GET request. Request headers can be configured, a JSONPath can be set for processing the response (no JSON parsing is done if this is not set), and the URL is allowed to contain environment variables in the format `"${var}"`.
The new flow for getting a unique machine id is:
1. PrivateIP (if enabled)
2. Hostname (if enabled)
3. Webhook (if enabled, to configured URL)
4. Give up and error out.
It's important that init configures machine identity first. Otherwise we could try to get an ID before configuring it. To prevent this from causing difficult to debug issues, where for example the default configuration was used, I've ensured that
the application will generate an error if the module hasn't been configured and you try to get an ID.
Misc changes:
* Spelling and gramatical corrections to `init.go::New()` long description.
* Spelling corrections to `verify_zitadel.go::newZitadel()`.
* Updated `production.md` and `development.md` based on the new build process. I think the run instructions are also out of date, but I'll leave that for someone else.
* `id.SonyFlakeGenerator` is now a function, which sets `id.sonyFlakeGenerator`, this allows us to defer initialization until configuration has been read.
* Update internal/id/config.go
Co-authored-by: Alexei-Barnes <82444470+Alexei-Barnes@users.noreply.github.com>
* Fix authored by @livio-a for tests
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-05-24 14:57:57 +00:00
|
|
|
name: "invalid name",
|
|
|
|
fields: fields{},
|
2022-04-12 14:20:17 +00:00
|
|
|
args: args{
|
|
|
|
app: &addOIDCApp{
|
|
|
|
AddApp: AddApp{
|
|
|
|
Aggregate: *agg,
|
|
|
|
ID: "id",
|
|
|
|
Name: "",
|
|
|
|
},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
Version: domain.OIDCVersionV1,
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
want: Want{
|
2023-12-08 14:30:55 +00:00
|
|
|
ValidationErr: zerrors.ThrowInvalidArgument(nil, "PROJE-Fef31", "Errors.Invalid.Argument"),
|
2022-04-12 14:20:17 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2024-02-12 08:56:55 +00:00
|
|
|
name: "project doesn't exist",
|
feat: Configurable Unique Machine Identification (#3626)
* feat: Configurable Unique Machine Identification
This change fixes Segfault on AWS App Runner with v2 #3625
The change introduces two new dependencies:
* github.com/drone/envsubst for supporting AWS ECS, which has its metadata endpoint described by an environment variable
* github.com/jarcoal/jpath so that only relevant data from a metadata response is used to identify the machine.
The change ads new configuration (see `defaults.yaml`):
* `Machine.Identification` enables configuration of how machines are uniquely identified - I'm not sure about the top level category `Machine`, as I don't have anything else to add to it. Happy to hear suggestions for better naming or structure here.
* `Machine.Identifiation.PrivateId` turns on or off the existing private IP based identification. Default is on.
* `Machine.Identification.Hostname` turns on or off using the OS hostname to identify the machine. Great for most cloud environments, where this tends to be set to something that identifies the machine uniquely. Enabled by default.
* `Machine.Identification.Webhook` configures identification based on the response to an HTTP GET request. Request headers can be configured, a JSONPath can be set for processing the response (no JSON parsing is done if this is not set), and the URL is allowed to contain environment variables in the format `"${var}"`.
The new flow for getting a unique machine id is:
1. PrivateIP (if enabled)
2. Hostname (if enabled)
3. Webhook (if enabled, to configured URL)
4. Give up and error out.
It's important that init configures machine identity first. Otherwise we could try to get an ID before configuring it. To prevent this from causing difficult to debug issues, where for example the default configuration was used, I've ensured that
the application will generate an error if the module hasn't been configured and you try to get an ID.
Misc changes:
* Spelling and gramatical corrections to `init.go::New()` long description.
* Spelling corrections to `verify_zitadel.go::newZitadel()`.
* Updated `production.md` and `development.md` based on the new build process. I think the run instructions are also out of date, but I'll leave that for someone else.
* `id.SonyFlakeGenerator` is now a function, which sets `id.sonyFlakeGenerator`, this allows us to defer initialization until configuration has been read.
* Update internal/id/config.go
Co-authored-by: Alexei-Barnes <82444470+Alexei-Barnes@users.noreply.github.com>
* Fix authored by @livio-a for tests
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-05-24 14:57:57 +00:00
|
|
|
fields: fields{},
|
2022-04-12 14:20:17 +00:00
|
|
|
args: args{
|
|
|
|
app: &addOIDCApp{
|
|
|
|
AddApp: AddApp{
|
|
|
|
Aggregate: *agg,
|
|
|
|
ID: "id",
|
|
|
|
Name: "name",
|
|
|
|
},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
Version: domain.OIDCVersionV1,
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
},
|
|
|
|
filter: NewMultiFilter().
|
|
|
|
Append(func(ctx context.Context, queryFactory *eventstore.SearchQueryBuilder) ([]eventstore.Event, error) {
|
|
|
|
return nil, nil
|
|
|
|
}).
|
|
|
|
Filter(),
|
|
|
|
},
|
|
|
|
want: Want{
|
2023-12-08 14:30:55 +00:00
|
|
|
CreateErr: zerrors.ThrowNotFound(nil, "PROJE-6swVG", ""),
|
2022-04-12 14:20:17 +00:00
|
|
|
},
|
|
|
|
},
|
2024-02-12 08:56:55 +00:00
|
|
|
{
|
|
|
|
name: "correct, using uris with whitespaces",
|
|
|
|
fields: fields{
|
|
|
|
idGenerator: id_mock.NewIDGeneratorExpectIDs(t, "clientID"),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
app: &addOIDCApp{
|
|
|
|
AddApp: AddApp{
|
|
|
|
Aggregate: *agg,
|
|
|
|
ID: "id",
|
|
|
|
Name: "name",
|
|
|
|
},
|
|
|
|
RedirectUris: []string{" https://test.ch "},
|
|
|
|
PostLogoutRedirectUris: []string{" https://test.ch/logout "},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
Version: domain.OIDCVersionV1,
|
|
|
|
AdditionalOrigins: []string{" https://sub.test.ch "},
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
},
|
|
|
|
filter: NewMultiFilter().
|
|
|
|
Append(func(ctx context.Context, queryFactory *eventstore.SearchQueryBuilder) ([]eventstore.Event, error) {
|
|
|
|
return []eventstore.Event{
|
|
|
|
project.NewProjectAddedEvent(
|
|
|
|
ctx,
|
|
|
|
&agg.Aggregate,
|
|
|
|
"project",
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
domain.PrivateLabelingSettingUnspecified,
|
|
|
|
),
|
|
|
|
}, nil
|
|
|
|
}).
|
|
|
|
Filter(),
|
|
|
|
},
|
|
|
|
want: Want{
|
|
|
|
Commands: []eventstore.Command{
|
|
|
|
project.NewApplicationAddedEvent(ctx, &agg.Aggregate,
|
|
|
|
"id",
|
|
|
|
"name",
|
|
|
|
),
|
|
|
|
project.NewOIDCConfigAddedEvent(ctx, &agg.Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"id",
|
2024-07-04 08:31:40 +00:00
|
|
|
"clientID",
|
2024-04-05 09:35:49 +00:00
|
|
|
"",
|
2024-02-12 08:56:55 +00:00
|
|
|
[]string{"https://test.ch"},
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypeNone,
|
|
|
|
[]string{"https://test.ch/logout"},
|
|
|
|
false,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
0,
|
|
|
|
[]string{"https://sub.test.ch"},
|
|
|
|
false,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-04-12 14:20:17 +00:00
|
|
|
{
|
|
|
|
name: "correct",
|
feat: Configurable Unique Machine Identification (#3626)
* feat: Configurable Unique Machine Identification
This change fixes Segfault on AWS App Runner with v2 #3625
The change introduces two new dependencies:
* github.com/drone/envsubst for supporting AWS ECS, which has its metadata endpoint described by an environment variable
* github.com/jarcoal/jpath so that only relevant data from a metadata response is used to identify the machine.
The change ads new configuration (see `defaults.yaml`):
* `Machine.Identification` enables configuration of how machines are uniquely identified - I'm not sure about the top level category `Machine`, as I don't have anything else to add to it. Happy to hear suggestions for better naming or structure here.
* `Machine.Identifiation.PrivateId` turns on or off the existing private IP based identification. Default is on.
* `Machine.Identification.Hostname` turns on or off using the OS hostname to identify the machine. Great for most cloud environments, where this tends to be set to something that identifies the machine uniquely. Enabled by default.
* `Machine.Identification.Webhook` configures identification based on the response to an HTTP GET request. Request headers can be configured, a JSONPath can be set for processing the response (no JSON parsing is done if this is not set), and the URL is allowed to contain environment variables in the format `"${var}"`.
The new flow for getting a unique machine id is:
1. PrivateIP (if enabled)
2. Hostname (if enabled)
3. Webhook (if enabled, to configured URL)
4. Give up and error out.
It's important that init configures machine identity first. Otherwise we could try to get an ID before configuring it. To prevent this from causing difficult to debug issues, where for example the default configuration was used, I've ensured that
the application will generate an error if the module hasn't been configured and you try to get an ID.
Misc changes:
* Spelling and gramatical corrections to `init.go::New()` long description.
* Spelling corrections to `verify_zitadel.go::newZitadel()`.
* Updated `production.md` and `development.md` based on the new build process. I think the run instructions are also out of date, but I'll leave that for someone else.
* `id.SonyFlakeGenerator` is now a function, which sets `id.sonyFlakeGenerator`, this allows us to defer initialization until configuration has been read.
* Update internal/id/config.go
Co-authored-by: Alexei-Barnes <82444470+Alexei-Barnes@users.noreply.github.com>
* Fix authored by @livio-a for tests
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-05-24 14:57:57 +00:00
|
|
|
fields: fields{
|
|
|
|
idGenerator: id_mock.NewIDGeneratorExpectIDs(t, "clientID"),
|
|
|
|
},
|
2022-04-12 14:20:17 +00:00
|
|
|
args: args{
|
|
|
|
app: &addOIDCApp{
|
|
|
|
AddApp: AddApp{
|
|
|
|
Aggregate: *agg,
|
|
|
|
ID: "id",
|
|
|
|
Name: "name",
|
|
|
|
},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
Version: domain.OIDCVersionV1,
|
|
|
|
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
},
|
|
|
|
filter: NewMultiFilter().
|
|
|
|
Append(func(ctx context.Context, queryFactory *eventstore.SearchQueryBuilder) ([]eventstore.Event, error) {
|
|
|
|
return []eventstore.Event{
|
|
|
|
project.NewProjectAddedEvent(
|
|
|
|
ctx,
|
|
|
|
&agg.Aggregate,
|
|
|
|
"project",
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
domain.PrivateLabelingSettingUnspecified,
|
|
|
|
),
|
|
|
|
}, nil
|
|
|
|
}).
|
|
|
|
Filter(),
|
|
|
|
},
|
2024-07-04 08:31:40 +00:00
|
|
|
want: Want{
|
|
|
|
Commands: []eventstore.Command{
|
|
|
|
project.NewApplicationAddedEvent(ctx, &agg.Aggregate,
|
|
|
|
"id",
|
|
|
|
"name",
|
|
|
|
),
|
|
|
|
project.NewOIDCConfigAddedEvent(ctx, &agg.Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"id",
|
|
|
|
"clientID",
|
|
|
|
"",
|
|
|
|
nil,
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypeNone,
|
|
|
|
nil,
|
|
|
|
false,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
0,
|
|
|
|
nil,
|
|
|
|
false,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "correct with old ID format",
|
|
|
|
fields: fields{
|
|
|
|
idGenerator: id_mock.NewIDGeneratorExpectIDs(t, "clientID@project"),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
app: &addOIDCApp{
|
|
|
|
AddApp: AddApp{
|
|
|
|
Aggregate: *agg,
|
|
|
|
ID: "id",
|
|
|
|
Name: "name",
|
|
|
|
},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
Version: domain.OIDCVersionV1,
|
|
|
|
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypeNone,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
},
|
|
|
|
filter: NewMultiFilter().
|
|
|
|
Append(func(ctx context.Context, queryFactory *eventstore.SearchQueryBuilder) ([]eventstore.Event, error) {
|
|
|
|
return []eventstore.Event{
|
|
|
|
project.NewProjectAddedEvent(
|
|
|
|
ctx,
|
|
|
|
&agg.Aggregate,
|
|
|
|
"project",
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
domain.PrivateLabelingSettingUnspecified,
|
|
|
|
),
|
|
|
|
}, nil
|
|
|
|
}).
|
|
|
|
Filter(),
|
|
|
|
},
|
2022-04-12 14:20:17 +00:00
|
|
|
want: Want{
|
|
|
|
Commands: []eventstore.Command{
|
|
|
|
project.NewApplicationAddedEvent(ctx, &agg.Aggregate,
|
|
|
|
"id",
|
|
|
|
"name",
|
|
|
|
),
|
|
|
|
project.NewOIDCConfigAddedEvent(ctx, &agg.Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"id",
|
feat: Configurable Unique Machine Identification (#3626)
* feat: Configurable Unique Machine Identification
This change fixes Segfault on AWS App Runner with v2 #3625
The change introduces two new dependencies:
* github.com/drone/envsubst for supporting AWS ECS, which has its metadata endpoint described by an environment variable
* github.com/jarcoal/jpath so that only relevant data from a metadata response is used to identify the machine.
The change ads new configuration (see `defaults.yaml`):
* `Machine.Identification` enables configuration of how machines are uniquely identified - I'm not sure about the top level category `Machine`, as I don't have anything else to add to it. Happy to hear suggestions for better naming or structure here.
* `Machine.Identifiation.PrivateId` turns on or off the existing private IP based identification. Default is on.
* `Machine.Identification.Hostname` turns on or off using the OS hostname to identify the machine. Great for most cloud environments, where this tends to be set to something that identifies the machine uniquely. Enabled by default.
* `Machine.Identification.Webhook` configures identification based on the response to an HTTP GET request. Request headers can be configured, a JSONPath can be set for processing the response (no JSON parsing is done if this is not set), and the URL is allowed to contain environment variables in the format `"${var}"`.
The new flow for getting a unique machine id is:
1. PrivateIP (if enabled)
2. Hostname (if enabled)
3. Webhook (if enabled, to configured URL)
4. Give up and error out.
It's important that init configures machine identity first. Otherwise we could try to get an ID before configuring it. To prevent this from causing difficult to debug issues, where for example the default configuration was used, I've ensured that
the application will generate an error if the module hasn't been configured and you try to get an ID.
Misc changes:
* Spelling and gramatical corrections to `init.go::New()` long description.
* Spelling corrections to `verify_zitadel.go::newZitadel()`.
* Updated `production.md` and `development.md` based on the new build process. I think the run instructions are also out of date, but I'll leave that for someone else.
* `id.SonyFlakeGenerator` is now a function, which sets `id.sonyFlakeGenerator`, this allows us to defer initialization until configuration has been read.
* Update internal/id/config.go
Co-authored-by: Alexei-Barnes <82444470+Alexei-Barnes@users.noreply.github.com>
* Fix authored by @livio-a for tests
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-05-24 14:57:57 +00:00
|
|
|
"clientID@project",
|
2024-04-05 09:35:49 +00:00
|
|
|
"",
|
2022-04-12 14:20:17 +00:00
|
|
|
nil,
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypeNone,
|
|
|
|
nil,
|
|
|
|
false,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
0,
|
|
|
|
nil,
|
2023-04-11 15:07:32 +00:00
|
|
|
false,
|
2022-04-12 14:20:17 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-04-05 09:35:49 +00:00
|
|
|
{
|
|
|
|
name: "with secret",
|
|
|
|
fields: fields{
|
|
|
|
idGenerator: id_mock.NewIDGeneratorExpectIDs(t, "clientID"),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
app: &addOIDCApp{
|
|
|
|
AddApp: AddApp{
|
|
|
|
Aggregate: *agg,
|
|
|
|
ID: "id",
|
|
|
|
Name: "name",
|
|
|
|
},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
Version: domain.OIDCVersionV1,
|
|
|
|
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypeBasic,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
},
|
|
|
|
filter: NewMultiFilter().
|
|
|
|
Append(func(ctx context.Context, queryFactory *eventstore.SearchQueryBuilder) ([]eventstore.Event, error) {
|
|
|
|
return []eventstore.Event{
|
|
|
|
project.NewProjectAddedEvent(
|
|
|
|
ctx,
|
|
|
|
&agg.Aggregate,
|
|
|
|
"project",
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
domain.PrivateLabelingSettingUnspecified,
|
|
|
|
),
|
|
|
|
}, nil
|
|
|
|
}).
|
|
|
|
Filter(),
|
|
|
|
},
|
|
|
|
want: Want{
|
|
|
|
Commands: []eventstore.Command{
|
|
|
|
project.NewApplicationAddedEvent(ctx, &agg.Aggregate,
|
|
|
|
"id",
|
|
|
|
"name",
|
|
|
|
),
|
|
|
|
project.NewOIDCConfigAddedEvent(ctx, &agg.Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"id",
|
2024-07-04 08:31:40 +00:00
|
|
|
"clientID",
|
2024-04-05 09:35:49 +00:00
|
|
|
"secret",
|
|
|
|
nil,
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypeBasic,
|
|
|
|
nil,
|
|
|
|
false,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
0,
|
|
|
|
nil,
|
|
|
|
false,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-04-12 14:20:17 +00:00
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
feat: Configurable Unique Machine Identification (#3626)
* feat: Configurable Unique Machine Identification
This change fixes Segfault on AWS App Runner with v2 #3625
The change introduces two new dependencies:
* github.com/drone/envsubst for supporting AWS ECS, which has its metadata endpoint described by an environment variable
* github.com/jarcoal/jpath so that only relevant data from a metadata response is used to identify the machine.
The change ads new configuration (see `defaults.yaml`):
* `Machine.Identification` enables configuration of how machines are uniquely identified - I'm not sure about the top level category `Machine`, as I don't have anything else to add to it. Happy to hear suggestions for better naming or structure here.
* `Machine.Identifiation.PrivateId` turns on or off the existing private IP based identification. Default is on.
* `Machine.Identification.Hostname` turns on or off using the OS hostname to identify the machine. Great for most cloud environments, where this tends to be set to something that identifies the machine uniquely. Enabled by default.
* `Machine.Identification.Webhook` configures identification based on the response to an HTTP GET request. Request headers can be configured, a JSONPath can be set for processing the response (no JSON parsing is done if this is not set), and the URL is allowed to contain environment variables in the format `"${var}"`.
The new flow for getting a unique machine id is:
1. PrivateIP (if enabled)
2. Hostname (if enabled)
3. Webhook (if enabled, to configured URL)
4. Give up and error out.
It's important that init configures machine identity first. Otherwise we could try to get an ID before configuring it. To prevent this from causing difficult to debug issues, where for example the default configuration was used, I've ensured that
the application will generate an error if the module hasn't been configured and you try to get an ID.
Misc changes:
* Spelling and gramatical corrections to `init.go::New()` long description.
* Spelling corrections to `verify_zitadel.go::newZitadel()`.
* Updated `production.md` and `development.md` based on the new build process. I think the run instructions are also out of date, but I'll leave that for someone else.
* `id.SonyFlakeGenerator` is now a function, which sets `id.sonyFlakeGenerator`, this allows us to defer initialization until configuration has been read.
* Update internal/id/config.go
Co-authored-by: Alexei-Barnes <82444470+Alexei-Barnes@users.noreply.github.com>
* Fix authored by @livio-a for tests
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-05-24 14:57:57 +00:00
|
|
|
c := Commands{
|
2024-04-05 09:35:49 +00:00
|
|
|
idGenerator: tt.fields.idGenerator,
|
|
|
|
newHashedSecret: mockHashedSecret("secret"),
|
|
|
|
defaultSecretGenerators: &SecretGenerators{
|
|
|
|
ClientSecret: emptyConfig,
|
|
|
|
},
|
feat: Configurable Unique Machine Identification (#3626)
* feat: Configurable Unique Machine Identification
This change fixes Segfault on AWS App Runner with v2 #3625
The change introduces two new dependencies:
* github.com/drone/envsubst for supporting AWS ECS, which has its metadata endpoint described by an environment variable
* github.com/jarcoal/jpath so that only relevant data from a metadata response is used to identify the machine.
The change ads new configuration (see `defaults.yaml`):
* `Machine.Identification` enables configuration of how machines are uniquely identified - I'm not sure about the top level category `Machine`, as I don't have anything else to add to it. Happy to hear suggestions for better naming or structure here.
* `Machine.Identifiation.PrivateId` turns on or off the existing private IP based identification. Default is on.
* `Machine.Identification.Hostname` turns on or off using the OS hostname to identify the machine. Great for most cloud environments, where this tends to be set to something that identifies the machine uniquely. Enabled by default.
* `Machine.Identification.Webhook` configures identification based on the response to an HTTP GET request. Request headers can be configured, a JSONPath can be set for processing the response (no JSON parsing is done if this is not set), and the URL is allowed to contain environment variables in the format `"${var}"`.
The new flow for getting a unique machine id is:
1. PrivateIP (if enabled)
2. Hostname (if enabled)
3. Webhook (if enabled, to configured URL)
4. Give up and error out.
It's important that init configures machine identity first. Otherwise we could try to get an ID before configuring it. To prevent this from causing difficult to debug issues, where for example the default configuration was used, I've ensured that
the application will generate an error if the module hasn't been configured and you try to get an ID.
Misc changes:
* Spelling and gramatical corrections to `init.go::New()` long description.
* Spelling corrections to `verify_zitadel.go::newZitadel()`.
* Updated `production.md` and `development.md` based on the new build process. I think the run instructions are also out of date, but I'll leave that for someone else.
* `id.SonyFlakeGenerator` is now a function, which sets `id.sonyFlakeGenerator`, this allows us to defer initialization until configuration has been read.
* Update internal/id/config.go
Co-authored-by: Alexei-Barnes <82444470+Alexei-Barnes@users.noreply.github.com>
* Fix authored by @livio-a for tests
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-05-24 14:57:57 +00:00
|
|
|
}
|
2022-04-12 14:20:17 +00:00
|
|
|
AssertValidation(t,
|
2022-07-28 11:18:31 +00:00
|
|
|
context.Background(),
|
feat: Configurable Unique Machine Identification (#3626)
* feat: Configurable Unique Machine Identification
This change fixes Segfault on AWS App Runner with v2 #3625
The change introduces two new dependencies:
* github.com/drone/envsubst for supporting AWS ECS, which has its metadata endpoint described by an environment variable
* github.com/jarcoal/jpath so that only relevant data from a metadata response is used to identify the machine.
The change ads new configuration (see `defaults.yaml`):
* `Machine.Identification` enables configuration of how machines are uniquely identified - I'm not sure about the top level category `Machine`, as I don't have anything else to add to it. Happy to hear suggestions for better naming or structure here.
* `Machine.Identifiation.PrivateId` turns on or off the existing private IP based identification. Default is on.
* `Machine.Identification.Hostname` turns on or off using the OS hostname to identify the machine. Great for most cloud environments, where this tends to be set to something that identifies the machine uniquely. Enabled by default.
* `Machine.Identification.Webhook` configures identification based on the response to an HTTP GET request. Request headers can be configured, a JSONPath can be set for processing the response (no JSON parsing is done if this is not set), and the URL is allowed to contain environment variables in the format `"${var}"`.
The new flow for getting a unique machine id is:
1. PrivateIP (if enabled)
2. Hostname (if enabled)
3. Webhook (if enabled, to configured URL)
4. Give up and error out.
It's important that init configures machine identity first. Otherwise we could try to get an ID before configuring it. To prevent this from causing difficult to debug issues, where for example the default configuration was used, I've ensured that
the application will generate an error if the module hasn't been configured and you try to get an ID.
Misc changes:
* Spelling and gramatical corrections to `init.go::New()` long description.
* Spelling corrections to `verify_zitadel.go::newZitadel()`.
* Updated `production.md` and `development.md` based on the new build process. I think the run instructions are also out of date, but I'll leave that for someone else.
* `id.SonyFlakeGenerator` is now a function, which sets `id.sonyFlakeGenerator`, this allows us to defer initialization until configuration has been read.
* Update internal/id/config.go
Co-authored-by: Alexei-Barnes <82444470+Alexei-Barnes@users.noreply.github.com>
* Fix authored by @livio-a for tests
Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2022-05-24 14:57:57 +00:00
|
|
|
c.AddOIDCAppCommand(
|
2022-04-12 14:20:17 +00:00
|
|
|
tt.args.app,
|
|
|
|
), tt.args.filter, tt.want)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-15 11:51:15 +00:00
|
|
|
func TestCommandSide_AddOIDCApplication(t *testing.T) {
|
|
|
|
type fields struct {
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore func(t *testing.T) *eventstore.Eventstore
|
2022-02-16 15:49:17 +00:00
|
|
|
idGenerator id.Generator
|
2021-03-15 11:51:15 +00:00
|
|
|
}
|
|
|
|
type args struct {
|
2024-04-05 09:35:49 +00:00
|
|
|
ctx context.Context
|
|
|
|
oidcApp *domain.OIDCApp
|
|
|
|
resourceOwner string
|
2021-03-15 11:51:15 +00:00
|
|
|
}
|
|
|
|
type res struct {
|
|
|
|
want *domain.OIDCApp
|
|
|
|
err func(error) bool
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
args args
|
|
|
|
res res
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "no aggregate id, invalid argument error",
|
|
|
|
fields: fields{
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore: expectEventstore(),
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
oidcApp: &domain.OIDCApp{},
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
2023-12-08 14:30:55 +00:00
|
|
|
err: zerrors.IsErrorInvalidArgument,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "project not existing, not found error",
|
|
|
|
fields: fields{
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore: expectEventstore(
|
2021-03-15 11:51:15 +00:00
|
|
|
expectFilter(),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
oidcApp: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
},
|
|
|
|
AppID: "app1",
|
|
|
|
AppName: "app",
|
|
|
|
},
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
2023-12-08 14:30:55 +00:00
|
|
|
err: zerrors.IsPreconditionFailed,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "invalid app, invalid argument error",
|
|
|
|
fields: fields{
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore: expectEventstore(
|
2021-03-15 11:51:15 +00:00
|
|
|
expectFilter(
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewProjectAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
2021-08-24 06:34:10 +00:00
|
|
|
"project", true, true, true,
|
|
|
|
domain.PrivateLabelingSettingUnspecified),
|
2021-03-15 11:51:15 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
oidcApp: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
},
|
|
|
|
AppID: "app1",
|
|
|
|
AppName: "",
|
|
|
|
},
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
2023-12-08 14:30:55 +00:00
|
|
|
err: zerrors.IsErrorInvalidArgument,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
},
|
2024-02-12 08:56:55 +00:00
|
|
|
{
|
|
|
|
name: "create oidc app basic using whitespaces in uris, ok",
|
|
|
|
fields: fields{
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore: expectEventstore(
|
2024-02-12 08:56:55 +00:00
|
|
|
expectFilter(
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewProjectAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
"project", true, true, true,
|
|
|
|
domain.PrivateLabelingSettingUnspecified),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
expectPush(
|
|
|
|
project.NewApplicationAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
"app1",
|
|
|
|
"app",
|
|
|
|
),
|
|
|
|
project.NewOIDCConfigAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"app1",
|
2024-07-04 08:31:40 +00:00
|
|
|
"client1",
|
2024-04-05 09:35:49 +00:00
|
|
|
"secret",
|
2024-02-12 08:56:55 +00:00
|
|
|
[]string{"https://test.ch"},
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypePost,
|
|
|
|
[]string{"https://test.ch/logout"},
|
|
|
|
true,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
time.Second*1,
|
|
|
|
[]string{"https://sub.test.ch"},
|
|
|
|
true,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
idGenerator: id_mock.NewIDGeneratorExpectIDs(t, "app1", "client1"),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
oidcApp: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
},
|
|
|
|
AppName: "app",
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypePost,
|
|
|
|
OIDCVersion: domain.OIDCVersionV1,
|
|
|
|
RedirectUris: []string{" https://test.ch "},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
PostLogoutRedirectUris: []string{" https://test.ch/logout "},
|
|
|
|
DevMode: true,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
AccessTokenRoleAssertion: true,
|
|
|
|
IDTokenRoleAssertion: true,
|
|
|
|
IDTokenUserinfoAssertion: true,
|
|
|
|
ClockSkew: time.Second * 1,
|
|
|
|
AdditionalOrigins: []string{" https://sub.test.ch "},
|
|
|
|
SkipNativeAppSuccessPage: true,
|
|
|
|
},
|
2024-04-05 09:35:49 +00:00
|
|
|
resourceOwner: "org1",
|
2024-02-12 08:56:55 +00:00
|
|
|
},
|
|
|
|
res: res{
|
|
|
|
want: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
ResourceOwner: "org1",
|
|
|
|
},
|
|
|
|
AppID: "app1",
|
|
|
|
AppName: "app",
|
2024-07-04 08:31:40 +00:00
|
|
|
ClientID: "client1",
|
2024-04-05 09:35:49 +00:00
|
|
|
ClientSecretString: "secret",
|
2024-02-12 08:56:55 +00:00
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypePost,
|
|
|
|
OIDCVersion: domain.OIDCVersionV1,
|
|
|
|
RedirectUris: []string{"https://test.ch"},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
PostLogoutRedirectUris: []string{"https://test.ch/logout"},
|
|
|
|
DevMode: true,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
AccessTokenRoleAssertion: true,
|
|
|
|
IDTokenRoleAssertion: true,
|
|
|
|
IDTokenUserinfoAssertion: true,
|
|
|
|
ClockSkew: time.Second * 1,
|
|
|
|
AdditionalOrigins: []string{"https://sub.test.ch"},
|
|
|
|
SkipNativeAppSuccessPage: true,
|
|
|
|
State: domain.AppStateActive,
|
|
|
|
Compliance: &domain.Compliance{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-03-15 11:51:15 +00:00
|
|
|
{
|
|
|
|
name: "create oidc app basic, ok",
|
|
|
|
fields: fields{
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore: expectEventstore(
|
2021-03-15 11:51:15 +00:00
|
|
|
expectFilter(
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewProjectAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
2021-08-24 06:34:10 +00:00
|
|
|
"project", true, true, true,
|
|
|
|
domain.PrivateLabelingSettingUnspecified),
|
2021-03-15 11:51:15 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
expectPush(
|
2023-10-19 10:19:10 +00:00
|
|
|
project.NewApplicationAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
"app1",
|
|
|
|
"app",
|
|
|
|
),
|
|
|
|
project.NewOIDCConfigAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"app1",
|
2024-07-04 08:31:40 +00:00
|
|
|
"client1",
|
2024-04-05 09:35:49 +00:00
|
|
|
"secret",
|
2023-10-19 10:19:10 +00:00
|
|
|
[]string{"https://test.ch"},
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypePost,
|
|
|
|
[]string{"https://test.ch/logout"},
|
|
|
|
true,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
time.Second*1,
|
|
|
|
[]string{"https://sub.test.ch"},
|
|
|
|
true,
|
|
|
|
),
|
2021-03-15 11:51:15 +00:00
|
|
|
),
|
|
|
|
),
|
2022-02-16 15:49:17 +00:00
|
|
|
idGenerator: id_mock.NewIDGeneratorExpectIDs(t, "app1", "client1"),
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
oidcApp: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
},
|
|
|
|
AppName: "app",
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypePost,
|
|
|
|
OIDCVersion: domain.OIDCVersionV1,
|
|
|
|
RedirectUris: []string{"https://test.ch"},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
PostLogoutRedirectUris: []string{"https://test.ch/logout"},
|
|
|
|
DevMode: true,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
AccessTokenRoleAssertion: true,
|
|
|
|
IDTokenRoleAssertion: true,
|
|
|
|
IDTokenUserinfoAssertion: true,
|
|
|
|
ClockSkew: time.Second * 1,
|
2021-05-19 07:17:38 +00:00
|
|
|
AdditionalOrigins: []string{"https://sub.test.ch"},
|
2023-04-11 15:07:32 +00:00
|
|
|
SkipNativeAppSuccessPage: true,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
2024-04-05 09:35:49 +00:00
|
|
|
resourceOwner: "org1",
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
res: res{
|
|
|
|
want: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
ResourceOwner: "org1",
|
|
|
|
},
|
|
|
|
AppID: "app1",
|
|
|
|
AppName: "app",
|
2024-07-04 08:31:40 +00:00
|
|
|
ClientID: "client1",
|
2024-04-05 09:35:49 +00:00
|
|
|
ClientSecretString: "secret",
|
2021-03-15 11:51:15 +00:00
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypePost,
|
|
|
|
OIDCVersion: domain.OIDCVersionV1,
|
|
|
|
RedirectUris: []string{"https://test.ch"},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
PostLogoutRedirectUris: []string{"https://test.ch/logout"},
|
|
|
|
DevMode: true,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
AccessTokenRoleAssertion: true,
|
|
|
|
IDTokenRoleAssertion: true,
|
|
|
|
IDTokenUserinfoAssertion: true,
|
|
|
|
ClockSkew: time.Second * 1,
|
2021-05-19 07:17:38 +00:00
|
|
|
AdditionalOrigins: []string{"https://sub.test.ch"},
|
2023-04-11 15:07:32 +00:00
|
|
|
SkipNativeAppSuccessPage: true,
|
2021-03-15 11:51:15 +00:00
|
|
|
State: domain.AppStateActive,
|
|
|
|
Compliance: &domain.Compliance{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
r := &Commands{
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore: tt.fields.eventstore(t),
|
|
|
|
idGenerator: tt.fields.idGenerator,
|
|
|
|
newHashedSecret: mockHashedSecret("secret"),
|
|
|
|
defaultSecretGenerators: &SecretGenerators{
|
|
|
|
ClientSecret: emptyConfig,
|
|
|
|
},
|
2021-03-15 11:51:15 +00:00
|
|
|
}
|
2024-04-05 09:35:49 +00:00
|
|
|
got, err := r.AddOIDCApplication(tt.args.ctx, tt.args.oidcApp, tt.args.resourceOwner)
|
2021-03-15 11:51:15 +00:00
|
|
|
if tt.res.err == nil {
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
if tt.res.err != nil && !tt.res.err(err) {
|
|
|
|
t.Errorf("got wrong err: %v ", err)
|
|
|
|
}
|
|
|
|
if tt.res.err == nil {
|
|
|
|
assert.Equal(t, tt.res.want, got)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCommandSide_ChangeOIDCApplication(t *testing.T) {
|
|
|
|
type fields struct {
|
|
|
|
eventstore *eventstore.Eventstore
|
|
|
|
}
|
|
|
|
type args struct {
|
|
|
|
ctx context.Context
|
|
|
|
oidcApp *domain.OIDCApp
|
|
|
|
resourceOwner string
|
|
|
|
}
|
|
|
|
type res struct {
|
|
|
|
want *domain.OIDCApp
|
|
|
|
err func(error) bool
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
args args
|
|
|
|
res res
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "invalid app, invalid argument error",
|
|
|
|
fields: fields{
|
|
|
|
eventstore: eventstoreExpect(
|
|
|
|
t,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
oidcApp: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
},
|
|
|
|
AppID: "app1",
|
|
|
|
},
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
2023-12-08 14:30:55 +00:00
|
|
|
err: zerrors.IsErrorInvalidArgument,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "missing appid, invalid argument error",
|
|
|
|
fields: fields{
|
|
|
|
eventstore: eventstoreExpect(
|
|
|
|
t,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
oidcApp: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
},
|
|
|
|
AppID: "",
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypePost,
|
2021-03-19 17:46:26 +00:00
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
2023-12-08 14:30:55 +00:00
|
|
|
err: zerrors.IsErrorInvalidArgument,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "missing aggregateid, invalid argument error",
|
|
|
|
fields: fields{
|
|
|
|
eventstore: eventstoreExpect(
|
|
|
|
t,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
oidcApp: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "",
|
|
|
|
},
|
|
|
|
AppID: "appid",
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypePost,
|
2021-03-19 17:46:26 +00:00
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
2023-12-08 14:30:55 +00:00
|
|
|
err: zerrors.IsErrorInvalidArgument,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "app not existing, not found error",
|
|
|
|
fields: fields{
|
|
|
|
eventstore: eventstoreExpect(
|
|
|
|
t,
|
|
|
|
expectFilter(),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
oidcApp: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
},
|
2021-03-19 17:46:26 +00:00
|
|
|
AppID: "app1",
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypePost,
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
2023-12-08 14:30:55 +00:00
|
|
|
err: zerrors.IsNotFound,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "no changes, precondition error",
|
|
|
|
fields: fields{
|
|
|
|
eventstore: eventstoreExpect(
|
|
|
|
t,
|
|
|
|
expectFilter(
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewApplicationAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
"app1",
|
|
|
|
"app",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewOIDCConfigAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"app1",
|
|
|
|
"client1@project",
|
2024-04-05 09:35:49 +00:00
|
|
|
"secret",
|
2021-03-15 11:51:15 +00:00
|
|
|
[]string{"https://test.ch"},
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypePost,
|
|
|
|
[]string{"https://test.ch/logout"},
|
|
|
|
true,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
2021-05-19 07:17:38 +00:00
|
|
|
time.Second*1,
|
2023-04-11 15:07:32 +00:00
|
|
|
[]string{"https://sub.test.ch"},
|
|
|
|
true,
|
|
|
|
),
|
2021-03-15 11:51:15 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
oidcApp: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
},
|
|
|
|
AppID: "app1",
|
|
|
|
AppName: "app",
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypePost,
|
|
|
|
OIDCVersion: domain.OIDCVersionV1,
|
|
|
|
RedirectUris: []string{"https://test.ch"},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
PostLogoutRedirectUris: []string{"https://test.ch/logout"},
|
|
|
|
DevMode: true,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
AccessTokenRoleAssertion: true,
|
|
|
|
IDTokenRoleAssertion: true,
|
|
|
|
IDTokenUserinfoAssertion: true,
|
|
|
|
ClockSkew: time.Second * 1,
|
2021-05-19 07:17:38 +00:00
|
|
|
AdditionalOrigins: []string{"https://sub.test.ch"},
|
2023-04-11 15:07:32 +00:00
|
|
|
SkipNativeAppSuccessPage: true,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
2023-12-08 14:30:55 +00:00
|
|
|
err: zerrors.IsPreconditionFailed,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
},
|
2024-02-12 08:56:55 +00:00
|
|
|
{
|
|
|
|
name: "no changes whitespaces are ignored, precondition error",
|
|
|
|
fields: fields{
|
|
|
|
eventstore: eventstoreExpect(
|
|
|
|
t,
|
|
|
|
expectFilter(
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewApplicationAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
"app1",
|
|
|
|
"app",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewOIDCConfigAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"app1",
|
|
|
|
"client1@project",
|
2024-04-05 09:35:49 +00:00
|
|
|
"secret",
|
2024-02-12 08:56:55 +00:00
|
|
|
[]string{"https://test.ch"},
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypePost,
|
|
|
|
[]string{"https://test.ch/logout"},
|
|
|
|
true,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
time.Second*1,
|
|
|
|
[]string{"https://sub.test.ch"},
|
|
|
|
true,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
oidcApp: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
},
|
|
|
|
AppID: "app1",
|
|
|
|
AppName: "app",
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypePost,
|
|
|
|
OIDCVersion: domain.OIDCVersionV1,
|
|
|
|
RedirectUris: []string{"https://test.ch "},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
PostLogoutRedirectUris: []string{" https://test.ch/logout"},
|
|
|
|
DevMode: true,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
AccessTokenRoleAssertion: true,
|
|
|
|
IDTokenRoleAssertion: true,
|
|
|
|
IDTokenUserinfoAssertion: true,
|
|
|
|
ClockSkew: time.Second * 1,
|
|
|
|
AdditionalOrigins: []string{" https://sub.test.ch "},
|
|
|
|
SkipNativeAppSuccessPage: true,
|
|
|
|
},
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
|
|
|
err: zerrors.IsPreconditionFailed,
|
|
|
|
},
|
|
|
|
},
|
2021-03-15 11:51:15 +00:00
|
|
|
{
|
|
|
|
name: "change oidc app, ok",
|
|
|
|
fields: fields{
|
|
|
|
eventstore: eventstoreExpect(
|
|
|
|
t,
|
|
|
|
expectFilter(
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewApplicationAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
"app1",
|
|
|
|
"app",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewOIDCConfigAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"app1",
|
|
|
|
"client1@project",
|
2024-04-05 09:35:49 +00:00
|
|
|
"secret",
|
2021-03-15 11:51:15 +00:00
|
|
|
[]string{"https://test.ch"},
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypePost,
|
|
|
|
[]string{"https://test.ch/logout"},
|
|
|
|
false,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
2021-05-19 07:17:38 +00:00
|
|
|
time.Second*1,
|
2023-04-11 15:07:32 +00:00
|
|
|
[]string{"https://sub.test.ch"},
|
|
|
|
true,
|
|
|
|
),
|
2021-03-15 11:51:15 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
expectPush(
|
2023-10-19 10:19:10 +00:00
|
|
|
newOIDCAppChangedEvent(context.Background(),
|
|
|
|
"app1",
|
|
|
|
"project1",
|
|
|
|
"org1"),
|
2021-03-15 11:51:15 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
oidcApp: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
},
|
|
|
|
AppID: "app1",
|
|
|
|
AppName: "app",
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypePost,
|
|
|
|
OIDCVersion: domain.OIDCVersionV1,
|
2024-02-12 08:56:55 +00:00
|
|
|
RedirectUris: []string{" https://test-change.ch "},
|
2021-03-15 11:51:15 +00:00
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
2024-02-12 08:56:55 +00:00
|
|
|
PostLogoutRedirectUris: []string{" https://test-change.ch/logout "},
|
2021-03-15 11:51:15 +00:00
|
|
|
DevMode: true,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeJWT,
|
|
|
|
AccessTokenRoleAssertion: false,
|
|
|
|
IDTokenRoleAssertion: false,
|
|
|
|
IDTokenUserinfoAssertion: false,
|
|
|
|
ClockSkew: time.Second * 2,
|
2021-05-19 07:17:38 +00:00
|
|
|
AdditionalOrigins: []string{"https://sub.test.ch"},
|
2023-04-11 15:07:32 +00:00
|
|
|
SkipNativeAppSuccessPage: true,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
|
|
|
want: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
ResourceOwner: "org1",
|
|
|
|
},
|
|
|
|
AppID: "app1",
|
|
|
|
ClientID: "client1@project",
|
|
|
|
AppName: "app",
|
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypePost,
|
|
|
|
OIDCVersion: domain.OIDCVersionV1,
|
|
|
|
RedirectUris: []string{"https://test-change.ch"},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
PostLogoutRedirectUris: []string{"https://test-change.ch/logout"},
|
|
|
|
DevMode: true,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeJWT,
|
|
|
|
AccessTokenRoleAssertion: false,
|
|
|
|
IDTokenRoleAssertion: false,
|
|
|
|
IDTokenUserinfoAssertion: false,
|
|
|
|
ClockSkew: time.Second * 2,
|
2021-05-19 07:17:38 +00:00
|
|
|
AdditionalOrigins: []string{"https://sub.test.ch"},
|
2023-04-11 15:07:32 +00:00
|
|
|
SkipNativeAppSuccessPage: true,
|
2021-03-15 11:51:15 +00:00
|
|
|
Compliance: &domain.Compliance{},
|
|
|
|
State: domain.AppStateActive,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
r := &Commands{
|
|
|
|
eventstore: tt.fields.eventstore,
|
|
|
|
}
|
|
|
|
got, err := r.ChangeOIDCApplication(tt.args.ctx, tt.args.oidcApp, tt.args.resourceOwner)
|
|
|
|
if tt.res.err == nil {
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
if tt.res.err != nil && !tt.res.err(err) {
|
|
|
|
t.Errorf("got wrong err: %v ", err)
|
|
|
|
}
|
|
|
|
if tt.res.err == nil {
|
|
|
|
assert.Equal(t, tt.res.want, got)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCommandSide_ChangeOIDCApplicationSecret(t *testing.T) {
|
|
|
|
type fields struct {
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore func(*testing.T) *eventstore.Eventstore
|
2021-03-15 11:51:15 +00:00
|
|
|
}
|
|
|
|
type args struct {
|
2024-04-05 09:35:49 +00:00
|
|
|
ctx context.Context
|
|
|
|
appID string
|
|
|
|
projectID string
|
|
|
|
resourceOwner string
|
2021-03-15 11:51:15 +00:00
|
|
|
}
|
|
|
|
type res struct {
|
|
|
|
want *domain.OIDCApp
|
|
|
|
err func(error) bool
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
args args
|
|
|
|
res res
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "no projectid, invalid argument error",
|
|
|
|
fields: fields{
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore: expectEventstore(),
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
appID: "app1",
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
2023-12-08 14:30:55 +00:00
|
|
|
err: zerrors.IsErrorInvalidArgument,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "no appid, invalid argument error",
|
|
|
|
fields: fields{
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore: expectEventstore(),
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
projectID: "project1",
|
|
|
|
appID: "",
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
2023-12-08 14:30:55 +00:00
|
|
|
err: zerrors.IsErrorInvalidArgument,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "app not existing, not found error",
|
|
|
|
fields: fields{
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore: expectEventstore(
|
2021-03-15 11:51:15 +00:00
|
|
|
expectFilter(),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
projectID: "project1",
|
|
|
|
appID: "app1",
|
|
|
|
resourceOwner: "org1",
|
|
|
|
},
|
|
|
|
res: res{
|
2023-12-08 14:30:55 +00:00
|
|
|
err: zerrors.IsNotFound,
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "change secret, ok",
|
|
|
|
fields: fields{
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore: expectEventstore(
|
2021-03-15 11:51:15 +00:00
|
|
|
expectFilter(
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewApplicationAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
"app1",
|
|
|
|
"app",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewOIDCConfigAddedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"app1",
|
|
|
|
"client1@project",
|
2024-04-05 09:35:49 +00:00
|
|
|
"secret",
|
2021-03-15 11:51:15 +00:00
|
|
|
[]string{"https://test.ch"},
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypePost,
|
|
|
|
[]string{"https://test.ch/logout"},
|
|
|
|
true,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
2021-05-19 07:17:38 +00:00
|
|
|
time.Second*1,
|
2023-04-11 15:07:32 +00:00
|
|
|
[]string{"https://sub.test.ch"},
|
|
|
|
false,
|
|
|
|
),
|
2021-03-15 11:51:15 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
expectPush(
|
2023-10-19 10:19:10 +00:00
|
|
|
project.NewOIDCConfigSecretChangedEvent(context.Background(),
|
|
|
|
&project.NewAggregate("project1", "org1").Aggregate,
|
|
|
|
"app1",
|
2024-04-05 09:35:49 +00:00
|
|
|
"secret",
|
2023-10-19 10:19:10 +00:00
|
|
|
),
|
2021-03-15 11:51:15 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
args: args{
|
2024-04-05 09:35:49 +00:00
|
|
|
ctx: context.Background(),
|
|
|
|
projectID: "project1",
|
|
|
|
appID: "app1",
|
|
|
|
resourceOwner: "org1",
|
2021-03-15 11:51:15 +00:00
|
|
|
},
|
|
|
|
res: res{
|
|
|
|
want: &domain.OIDCApp{
|
|
|
|
ObjectRoot: models.ObjectRoot{
|
|
|
|
AggregateID: "project1",
|
|
|
|
ResourceOwner: "org1",
|
|
|
|
},
|
|
|
|
AppID: "app1",
|
|
|
|
AppName: "app",
|
|
|
|
ClientID: "client1@project",
|
2024-04-05 09:35:49 +00:00
|
|
|
ClientSecretString: "secret",
|
2021-03-15 11:51:15 +00:00
|
|
|
AuthMethodType: domain.OIDCAuthMethodTypePost,
|
|
|
|
OIDCVersion: domain.OIDCVersionV1,
|
|
|
|
RedirectUris: []string{"https://test.ch"},
|
|
|
|
ResponseTypes: []domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
GrantTypes: []domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
ApplicationType: domain.OIDCApplicationTypeWeb,
|
|
|
|
PostLogoutRedirectUris: []string{"https://test.ch/logout"},
|
|
|
|
DevMode: true,
|
|
|
|
AccessTokenType: domain.OIDCTokenTypeBearer,
|
|
|
|
AccessTokenRoleAssertion: true,
|
|
|
|
IDTokenRoleAssertion: true,
|
|
|
|
IDTokenUserinfoAssertion: true,
|
|
|
|
ClockSkew: time.Second * 1,
|
2021-05-19 07:17:38 +00:00
|
|
|
AdditionalOrigins: []string{"https://sub.test.ch"},
|
2023-04-11 15:07:32 +00:00
|
|
|
SkipNativeAppSuccessPage: false,
|
2021-03-15 11:51:15 +00:00
|
|
|
State: domain.AppStateActive,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
2024-04-05 09:35:49 +00:00
|
|
|
t.Run(tt.name, func(*testing.T) {
|
2021-03-15 11:51:15 +00:00
|
|
|
r := &Commands{
|
2024-04-05 09:35:49 +00:00
|
|
|
eventstore: tt.fields.eventstore(t),
|
|
|
|
newHashedSecret: mockHashedSecret("secret"),
|
|
|
|
defaultSecretGenerators: &SecretGenerators{
|
|
|
|
ClientSecret: emptyConfig,
|
|
|
|
},
|
2021-03-15 11:51:15 +00:00
|
|
|
}
|
2024-04-05 09:35:49 +00:00
|
|
|
got, err := r.ChangeOIDCApplicationSecret(tt.args.ctx, tt.args.projectID, tt.args.appID, tt.args.resourceOwner)
|
2021-03-15 11:51:15 +00:00
|
|
|
if tt.res.err == nil {
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
if tt.res.err != nil && !tt.res.err(err) {
|
|
|
|
t.Errorf("got wrong err: %v ", err)
|
|
|
|
}
|
|
|
|
if tt.res.err == nil {
|
|
|
|
assert.Equal(t, tt.res.want, got)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func newOIDCAppChangedEvent(ctx context.Context, appID, projectID, resourceOwner string) *project.OIDCConfigChangedEvent {
|
|
|
|
changes := []project.OIDCConfigChanges{
|
|
|
|
project.ChangeRedirectURIs([]string{"https://test-change.ch"}),
|
|
|
|
project.ChangePostLogoutRedirectURIs([]string{"https://test-change.ch/logout"}),
|
|
|
|
project.ChangeDevMode(true),
|
|
|
|
project.ChangeAccessTokenType(domain.OIDCTokenTypeJWT),
|
|
|
|
project.ChangeAccessTokenRoleAssertion(false),
|
|
|
|
project.ChangeIDTokenRoleAssertion(false),
|
|
|
|
project.ChangeIDTokenUserinfoAssertion(false),
|
|
|
|
project.ChangeClockSkew(time.Second * 2),
|
|
|
|
}
|
|
|
|
event, _ := project.NewOIDCConfigChangedEvent(ctx,
|
|
|
|
&project.NewAggregate(projectID, resourceOwner).Aggregate,
|
|
|
|
appID,
|
|
|
|
changes,
|
|
|
|
)
|
|
|
|
return event
|
|
|
|
}
|
2024-04-05 09:35:49 +00:00
|
|
|
|
|
|
|
func TestCommands_VerifyOIDCClientSecret(t *testing.T) {
|
|
|
|
hasher := &crypto.Hasher{
|
|
|
|
Swapper: passwap.NewSwapper(bcrypt.New(bcrypt.MinCost)),
|
|
|
|
}
|
|
|
|
hashedSecret, err := hasher.Hash("secret")
|
|
|
|
require.NoError(t, err)
|
|
|
|
agg := project.NewAggregate("projectID", "orgID")
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
secret string
|
|
|
|
eventstore func(*testing.T) *eventstore.Eventstore
|
|
|
|
wantErr error
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "filter error",
|
|
|
|
eventstore: expectEventstore(
|
|
|
|
expectFilterError(io.ErrClosedPipe),
|
|
|
|
),
|
|
|
|
wantErr: io.ErrClosedPipe,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "app not exists",
|
|
|
|
eventstore: expectEventstore(
|
|
|
|
expectFilter(),
|
|
|
|
),
|
|
|
|
wantErr: zerrors.ThrowPreconditionFailed(nil, "COMMAND-D8hba", "Errors.Project.App.NotExisting"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "wrong app type",
|
|
|
|
eventstore: expectEventstore(
|
|
|
|
expectFilter(
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewApplicationAddedEvent(context.Background(), &agg.Aggregate, "appID", "appName"),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
wantErr: zerrors.ThrowInvalidArgument(nil, "COMMAND-BHgn2", "Errors.Project.App.IsNotOIDC"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "no secret set",
|
|
|
|
eventstore: expectEventstore(
|
|
|
|
expectFilter(
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewApplicationAddedEvent(context.Background(), &agg.Aggregate, "appID", "appName"),
|
|
|
|
),
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewOIDCConfigAddedEvent(context.Background(),
|
|
|
|
&agg.Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"appID",
|
|
|
|
"client1@project",
|
|
|
|
"",
|
|
|
|
[]string{"https://test.ch"},
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypePost,
|
|
|
|
[]string{"https://test.ch/logout"},
|
|
|
|
true,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
time.Second*1,
|
|
|
|
[]string{"https://sub.test.ch"},
|
|
|
|
false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
wantErr: zerrors.ThrowPreconditionFailed(nil, "COMMAND-D6hba", "Errors.Project.App.OIDCConfigInvalid"),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "check succeeded",
|
|
|
|
secret: "secret",
|
|
|
|
eventstore: expectEventstore(
|
|
|
|
expectFilter(
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewApplicationAddedEvent(context.Background(), &agg.Aggregate, "appID", "appName"),
|
|
|
|
),
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewOIDCConfigAddedEvent(context.Background(),
|
|
|
|
&agg.Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"appID",
|
|
|
|
"client1@project",
|
|
|
|
hashedSecret,
|
|
|
|
[]string{"https://test.ch"},
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypePost,
|
|
|
|
[]string{"https://test.ch/logout"},
|
|
|
|
true,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
time.Second*1,
|
|
|
|
[]string{"https://sub.test.ch"},
|
|
|
|
false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
expectPush(
|
|
|
|
project.NewOIDCConfigSecretCheckSucceededEvent(context.Background(), &agg.Aggregate, "appID"),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "check failed",
|
|
|
|
secret: "wrong!",
|
|
|
|
eventstore: expectEventstore(
|
|
|
|
expectFilter(
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewApplicationAddedEvent(context.Background(), &agg.Aggregate, "appID", "appName"),
|
|
|
|
),
|
|
|
|
eventFromEventPusher(
|
|
|
|
project.NewOIDCConfigAddedEvent(context.Background(),
|
|
|
|
&agg.Aggregate,
|
|
|
|
domain.OIDCVersionV1,
|
|
|
|
"appID",
|
|
|
|
"client1@project",
|
|
|
|
hashedSecret,
|
|
|
|
[]string{"https://test.ch"},
|
|
|
|
[]domain.OIDCResponseType{domain.OIDCResponseTypeCode},
|
|
|
|
[]domain.OIDCGrantType{domain.OIDCGrantTypeAuthorizationCode},
|
|
|
|
domain.OIDCApplicationTypeWeb,
|
|
|
|
domain.OIDCAuthMethodTypePost,
|
|
|
|
[]string{"https://test.ch/logout"},
|
|
|
|
true,
|
|
|
|
domain.OIDCTokenTypeBearer,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
time.Second*1,
|
|
|
|
[]string{"https://sub.test.ch"},
|
|
|
|
false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
expectPush(
|
|
|
|
project.NewOIDCConfigSecretCheckFailedEvent(context.Background(), &agg.Aggregate, "appID"),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
wantErr: zerrors.ThrowInvalidArgument(err, "COMMAND-Bz542", "Errors.Project.App.ClientSecretInvalid"),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
c := &Commands{
|
|
|
|
eventstore: tt.eventstore(t),
|
|
|
|
secretHasher: hasher,
|
|
|
|
}
|
|
|
|
err := c.VerifyOIDCClientSecret(context.Background(), "projectID", "appID", tt.secret)
|
|
|
|
c.jobs.Wait()
|
|
|
|
require.ErrorIs(t, err, tt.wantErr)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|