Skip to content

Commit c47656c

Browse files
committed
chore: use email from token when creating a demo organization
Signed-off-by: Alessandro Yuichi Okimoto <yuichijpn@gmail.com>
1 parent 70ff7cd commit c47656c

9 files changed

Lines changed: 1185 additions & 1256 deletions

File tree

api-description/web-api.swagger.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10776,14 +10776,11 @@ definitions:
1077610776
type: string
1077710777
urlCode:
1077810778
type: string
10779-
ownerEmail:
10780-
type: string
1078110779
description:
1078210780
type: string
1078310781
required:
1078410782
- name
1078510783
- urlCode
10786-
- ownerEmail
1078710784
environmentCreateDemoOrganizationResponse:
1078810785
type: object
1078910786
properties:

pkg/environment/api/api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func createDemoContextWithToken(t *testing.T) context.Context {
7171
Audience: "audience",
7272
Expiry: time.Now().AddDate(100, 0, 0),
7373
IssuedAt: time.Now(),
74-
Email: "email",
74+
Email: "test@example.com",
7575
}
7676
ctx := context.TODO()
7777
return context.WithValue(ctx, rpc.Key, token)

pkg/environment/api/organization.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (s *EnvironmentService) CreateDemoOrganization(
250250
ctx,
251251
req.Name,
252252
req.UrlCode,
253-
req.OwnerEmail,
253+
demoToken.Email,
254254
req.Description,
255255
false,
256256
false,
@@ -344,18 +344,6 @@ func validateCreateDemoOrganizationRequest(
344344
}
345345
return dt.Err()
346346
}
347-
348-
req.OwnerEmail = strings.TrimSpace(req.OwnerEmail)
349-
if !emailRegex.MatchString(req.OwnerEmail) {
350-
dt, err := statusInvalidOrganizationCreatorEmail.WithDetails(&errdetails.LocalizedMessage{
351-
Locale: localizer.GetLocale(),
352-
Message: localizer.MustLocalizeWithTemplate(locale.InvalidArgumentError, "owner_email"),
353-
})
354-
if err != nil {
355-
return statusInternal.Err()
356-
}
357-
return dt.Err()
358-
}
359347
return nil
360348
}
361349

pkg/environment/api/organization_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func TestCreateOrganizationMySQL(t *testing.T) {
196196
orgExpected, err := domain.NewOrganization(
197197
"name",
198198
"url-code",
199-
"test@test.org",
199+
"test@example.com",
200200
"description",
201201
false,
202202
false,
@@ -1147,7 +1147,7 @@ func TestEnvironmentService_CreateDemoOrganization(t *testing.T) {
11471147
orgExpected, err := domain.NewOrganization(
11481148
"name",
11491149
"url-code",
1150-
"test@test.org",
1150+
"test@example.com",
11511151
"description",
11521152
false,
11531153
false,
@@ -1198,7 +1198,7 @@ func TestEnvironmentService_CreateDemoOrganization(t *testing.T) {
11981198
gomock.Any(), gomock.Any(),
11991199
).Return(v2es.ErrOrganizationAlreadyExists)
12001200
},
1201-
req: &proto.CreateDemoOrganizationRequest{Name: "id-0", UrlCode: "id-0", OwnerEmail: "test@test.org"},
1201+
req: &proto.CreateDemoOrganizationRequest{Name: "id-0", UrlCode: "id-0"},
12021202
expectedErr: createError(statusOrganizationAlreadyExists, localizer.MustLocalize(locale.AlreadyExistsError)),
12031203
},
12041204
{
@@ -1208,7 +1208,7 @@ func TestEnvironmentService_CreateDemoOrganization(t *testing.T) {
12081208
gomock.Any(), gomock.Any(),
12091209
).Return(errors.New("error"))
12101210
},
1211-
req: &proto.CreateDemoOrganizationRequest{Name: "id-1", UrlCode: "id-1", OwnerEmail: "test@test.org"},
1211+
req: &proto.CreateDemoOrganizationRequest{Name: "id-1", UrlCode: "id-1"},
12121212
expectedErr: createError(statusInternal, localizer.MustLocalize(locale.InternalServerError)),
12131213
},
12141214
{
@@ -1237,7 +1237,6 @@ func TestEnvironmentService_CreateDemoOrganization(t *testing.T) {
12371237
Name: orgExpected.Name,
12381238
UrlCode: orgExpected.UrlCode,
12391239
Description: orgExpected.Description,
1240-
OwnerEmail: "test@test.org",
12411240
},
12421241
expected: orgExpected.Organization,
12431242
expectedErr: nil,

proto/environment/service.pb.go

Lines changed: 1173 additions & 1183 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/environment/service.proto

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,7 @@ message DemoCreationToken {
404404
message CreateDemoOrganizationRequest {
405405
string name = 1 [(google.api.field_behavior) = REQUIRED];
406406
string url_code = 2 [(google.api.field_behavior) = REQUIRED];
407-
string owner_email = 3 [(google.api.field_behavior) = REQUIRED];
408-
string description = 4;
407+
string description = 3;
409408
}
410409

411410
message CreateDemoOrganizationResponse {

proto/proto.lock

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14722,17 +14722,6 @@
1472214722
},
1472314723
{
1472414724
"id": 3,
14725-
"name": "owner_email",
14726-
"type": "string",
14727-
"options": [
14728-
{
14729-
"name": "(google.api.field_behavior)",
14730-
"value": "REQUIRED"
14731-
}
14732-
]
14733-
},
14734-
{
14735-
"id": 4,
1473614725
"name": "description",
1473714726
"type": "string"
1473814727
}

ui/web-v2/src/proto/environment/service_pb.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,9 +2151,6 @@ export class CreateDemoOrganizationRequest extends jspb.Message {
21512151
getUrlCode(): string;
21522152
setUrlCode(value: string): void;
21532153

2154-
getOwnerEmail(): string;
2155-
setOwnerEmail(value: string): void;
2156-
21572154
getDescription(): string;
21582155
setDescription(value: string): void;
21592156

@@ -2182,7 +2179,6 @@ export namespace CreateDemoOrganizationRequest {
21822179
export type AsObject = {
21832180
name: string;
21842181
urlCode: string;
2185-
ownerEmail: string;
21862182
description: string;
21872183
};
21882184
}

ui/web-v2/src/proto/environment/service_pb.js

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12593,8 +12593,7 @@ if (jspb.Message.GENERATE_TO_OBJECT) {
1259312593
obj = {
1259412594
name: jspb.Message.getFieldWithDefault(msg, 1, ''),
1259512595
urlCode: jspb.Message.getFieldWithDefault(msg, 2, ''),
12596-
ownerEmail: jspb.Message.getFieldWithDefault(msg, 3, ''),
12597-
description: jspb.Message.getFieldWithDefault(msg, 4, '')
12596+
description: jspb.Message.getFieldWithDefault(msg, 3, '')
1259812597
};
1259912598

1260012599
if (includeInstance) {
@@ -12643,10 +12642,6 @@ proto.bucketeer.environment.CreateDemoOrganizationRequest.deserializeBinaryFromR
1264312642
msg.setUrlCode(value);
1264412643
break;
1264512644
case 3:
12646-
var value = /** @type {string} */ (reader.readString());
12647-
msg.setOwnerEmail(value);
12648-
break;
12649-
case 4:
1265012645
var value = /** @type {string} */ (reader.readString());
1265112646
msg.setDescription(value);
1265212647
break;
@@ -12690,13 +12685,9 @@ proto.bucketeer.environment.CreateDemoOrganizationRequest.serializeBinaryToWrite
1269012685
if (f.length > 0) {
1269112686
writer.writeString(2, f);
1269212687
}
12693-
f = message.getOwnerEmail();
12694-
if (f.length > 0) {
12695-
writer.writeString(3, f);
12696-
}
1269712688
f = message.getDescription();
1269812689
if (f.length > 0) {
12699-
writer.writeString(4, f);
12690+
writer.writeString(3, f);
1270012691
}
1270112692
};
1270212693

@@ -12741,33 +12732,13 @@ proto.bucketeer.environment.CreateDemoOrganizationRequest.prototype.setUrlCode =
1274112732
};
1274212733

1274312734
/**
12744-
* optional string owner_email = 3;
12745-
* @return {string}
12746-
*/
12747-
proto.bucketeer.environment.CreateDemoOrganizationRequest.prototype.getOwnerEmail =
12748-
function () {
12749-
return /** @type {string} */ (
12750-
jspb.Message.getFieldWithDefault(this, 3, '')
12751-
);
12752-
};
12753-
12754-
/**
12755-
* @param {string} value
12756-
* @return {!proto.bucketeer.environment.CreateDemoOrganizationRequest} returns this
12757-
*/
12758-
proto.bucketeer.environment.CreateDemoOrganizationRequest.prototype.setOwnerEmail =
12759-
function (value) {
12760-
return jspb.Message.setProto3StringField(this, 3, value);
12761-
};
12762-
12763-
/**
12764-
* optional string description = 4;
12735+
* optional string description = 3;
1276512736
* @return {string}
1276612737
*/
1276712738
proto.bucketeer.environment.CreateDemoOrganizationRequest.prototype.getDescription =
1276812739
function () {
1276912740
return /** @type {string} */ (
12770-
jspb.Message.getFieldWithDefault(this, 4, '')
12741+
jspb.Message.getFieldWithDefault(this, 3, '')
1277112742
);
1277212743
};
1277312744

@@ -12777,7 +12748,7 @@ proto.bucketeer.environment.CreateDemoOrganizationRequest.prototype.getDescripti
1277712748
*/
1277812749
proto.bucketeer.environment.CreateDemoOrganizationRequest.prototype.setDescription =
1277912750
function (value) {
12780-
return jspb.Message.setProto3StringField(this, 4, value);
12751+
return jspb.Message.setProto3StringField(this, 3, value);
1278112752
};
1278212753

1278312754
if (jspb.Message.GENERATE_TO_OBJECT) {

0 commit comments

Comments
 (0)