#1674 make sure login data is downcased. included tests to check as well

This commit is contained in:
Muhammad Nuzaihan 2017-11-25 00:49:40 +08:00
parent 6c707dc5f5
commit 1a9a23ce0e
No known key found for this signature in database
GPG key ID: 949F5D5715249C07
6 changed files with 557 additions and 0 deletions

View file

@ -68,6 +68,7 @@ module Import
mapped[:created_at] ||= DateTime.current mapped[:created_at] ||= DateTime.current
mapped[:updated_at] ||= DateTime.current mapped[:updated_at] ||= DateTime.current
mapped[:email].downcase! mapped[:email].downcase!
mapped[:login].downcase!
mapped mapped
end end

View file

@ -68,6 +68,7 @@ module Import
def map(user) def map(user)
mapped = map_default(user) mapped = map_default(user)
mapped[:email].downcase! mapped[:email].downcase!
mapped[:login].downcase!
mapped mapped
end end

View file

@ -0,0 +1,348 @@
{
"CustomerCompanyCity": "test712259",
"Config": {
"CustomerUserEmailUniqCheck": 1,
"CustomerUserSearchListLimit": 250,
"CustomerCompanySupport": 1,
"CustomerValid": "valid_id",
"CustomerUserSearchFields": [
"login",
"first_name",
"last_name",
"customer_id"
],
"CustomerUserSearchPrefix": "*",
"Params": {
"Table": "customer_user",
"CaseSensitive": 0
},
"CustomerUserListFields": [
"first_name",
"last_name",
"email"
],
"Map": [
[
"UserTitle",
"Title",
"title",
1,
0,
"var",
"",
0
],
[
"UserFirstname",
"Firstname",
"first_name",
1,
1,
"var",
"",
0
],
[
"UserLastname",
"Lastname",
"last_name",
1,
1,
"var",
"",
0
],
[
"UserLogin",
"Username",
"login",
1,
1,
"var",
"",
0
],
[
"UserPassword",
"Password",
"pw",
0,
0,
"var",
"",
0
],
[
"UserEmail",
"Email",
"email",
1,
1,
"var",
"",
0
],
[
"UserCustomerID",
"CustomerID",
"customer_id",
0,
1,
"var",
"",
0
],
[
"UserPhone",
"Phone",
"phone",
1,
0,
"var",
"",
0
],
[
"UserFax",
"Fax",
"fax",
1,
0,
"var",
"",
0
],
[
"UserMobile",
"Mobile",
"mobile",
1,
0,
"var",
"",
0
],
[
"UserStreet",
"Street",
"street",
1,
0,
"var",
"",
0
],
[
"UserZip",
"Zip",
"zip",
1,
0,
"var",
"",
0
],
[
"UserCity",
"City",
"city",
1,
0,
"var",
"",
0
],
[
"UserCountry",
"Country",
"country",
1,
0,
"var",
"",
0
],
[
"UserComment",
"Comment",
"comments",
1,
0,
"var",
"",
0
],
[
"ValidID",
"Valid",
"valid_id",
0,
1,
"int",
"",
0
]
],
"CustomerKey": "login",
"CustomerUserSearchSuffix": "*",
"Module": "Kernel::System::CustomerUser::DB",
"CacheTTL": 86400,
"Selections": {},
"CustomerID": "customer_id",
"Name": "Database Backend",
"CustomerUserPostMasterSearchFields": [
"email"
],
"CustomerUserNameFields": [
"title",
"first_name",
"last_name"
]
},
"UserCustomerID": "test712259",
"CustomerCompanyComment": "test712259",
"Source": "CustomerUser",
"UserTitle": "",
"CompanyConfig": {
"CustomerCompanySearchFields": [
"customer_id",
"name"
],
"CustomerCompanyListFields": [
"customer_id",
"name"
],
"Module": "Kernel::System::CustomerCompany::DB",
"CustomerCompanyKey": "customer_id",
"CustomerCompanySearchSuffix": "*",
"CacheTTL": 86400,
"CustomerCompanySearchListLimit": 250,
"CustomerCompanySearchPrefix": "",
"CustomerCompanyValid": "valid_id",
"Params": {
"Table": "customer_company",
"CaseSensitive": 0
},
"Map": [
[
"CustomerID",
"CustomerID",
"customer_id",
0,
1,
"var",
"",
0
],
[
"CustomerCompanyName",
"Customer",
"name",
1,
1,
"var",
"",
0
],
[
"CustomerCompanyStreet",
"Street",
"street",
1,
0,
"var",
"",
0
],
[
"CustomerCompanyZIP",
"Zip",
"zip",
1,
0,
"var",
"",
0
],
[
"CustomerCompanyCity",
"City",
"city",
1,
0,
"var",
"",
0
],
[
"CustomerCompanyCountry",
"Country",
"country",
1,
0,
"var",
"",
0
],
[
"CustomerCompanyURL",
"URL",
"url",
1,
0,
"var",
"[% Data.CustomerCompanyURL | html %]",
0
],
[
"CustomerCompanyComment",
"Comment",
"comments",
1,
0,
"var",
"",
0
],
[
"ValidID",
"Valid",
"valid_id",
0,
1,
"int",
"",
0
]
],
"Name": "Database Backend"
},
"UserZip": null,
"UserLastname": "test669673",
"ChangeBy": "1",
"CreateTime": "2014-06-07 02:31:31",
"UserLogin": "TeSt669673",
"UserPhone": null,
"CustomerID": "test712259",
"CustomerCompanyValidID": "1",
"CustomerCompanyZIP": "test712259",
"UserCountry": null,
"UserPassword": "f8be19af2f25837a31eff9131b0e47a5173290652c04a48b49b86474d48825ee",
"ValidID": "1",
"UserRefreshTime": "0",
"UserEmail": "QA100@t-Online.de",
"UserComment": "",
"UserID": "test669673",
"UserFirstname": "test669673",
"CustomerCompanyCountry": "test712259",
"UserFax": null,
"CreateBy": "1",
"ChangeTime": "2014-06-07 02:31:31",
"UserShowTickets": "25",
"UserStreet": null,
"CustomerCompanyURL": "test712259",
"CustomerCompanyName": "test712259",
"UserMobile": null,
"CustomerCompanyStreet": "test712259",
"UserCity": null
}

View file

@ -0,0 +1,135 @@
{
"OutOfOffice": "1",
"OutOfOfficeStartMonth": "9",
"UserStoredFilterColumns-AgentTicketLockedView": "{}",
"UserTicketOverviewSmallPageShown": "35",
"UserCreateWorkOrderNextMask": "AgentITSMWorkOrderZoom",
"OutOfOfficeEndYear": "2014",
"UserDashboardTicketGenericFilter0110-TicketEscalation": "All",
"UserDashboardPref0120-TicketNew-Columns": "{\"Columns\":{\"Changed\":0,\"CustomerID\":0,\"CustomerName\":0,\"CustomerUserID\":0,\"DynamicField_CustomerLocation\":0,\"EscalationResponseTime\":0,\"EscalationSolutionTime\":0,\"EscalationTime\":0,\"EscalationUpdateTime\":0,\"Lock\":0,\"Owner\":0,\"PendingTime\":0,\"Priority\":0,\"Responsible\":0,\"SLA\":0,\"State\":0,\"Type\":0,\"Age\":1,\"Title\":1,\"Queue\":1,\"Service\":1,\"TicketNumber\":1},\"Order\":[\"Age\",\"Title\",\"Queue\",\"Service\",\"TicketNumber\"]}",
"UserLastUsedZoomViewType": "",
"OutOfOfficeStartDay": "10",
"UserStoredFilterColumns-AgentTicketStatusView": "{}",
"UserTitle": null,
"UserLastname": "OTRS",
"UserTicketOverviewMediumPageShown": "20",
"OutOfOfficeEndDay": "12",
"CreateTime": "2014-04-28 10:53:18",
"UserTicketOverviewPreviewPageShown": "15",
"UserLogin": "rOoT@LoCaLhOsT",
"UserFilterColumnsEnabled-AgentTicketEscalationView": "[\"TicketNumber\",\"Age\",\"EscalationTime\",\"EscalationResponseTime\",\"EscalationSolutionTime\",\"EscalationUpdateTime\",\"Title\",\"State\",\"Lock\",\"Queue\",\"Owner\",\"CustomerID\"]",
"UserLanguage": "de",
"UserDashboardPref0110-TicketEscalation-Columns": "{\"Columns\":{\"Changed\":0,\"CustomerID\":0,\"CustomerUserID\":0,\"EscalationResponseTime\":0,\"EscalationSolutionTime\":0,\"EscalationTime\":0,\"EscalationUpdateTime\":0,\"Lock\":0,\"Owner\":0,\"PendingTime\":0,\"Priority\":0,\"Queue\":0,\"Responsible\":0,\"SLA\":0,\"Service\":0,\"State\":0,\"Type\":0,\"Age\":1,\"Title\":1,\"CustomerName\":1,\"TicketNumber\":1},\"Order\":[\"Age\",\"Title\",\"CustomerName\",\"TicketNumber\"]}",
"OutOfOfficeStartYear": "2014",
"UserDashboardPref0120-TicketNew-Shown": "10",
"UserFullname": "Admin OTRS",
"UserLastLoginTimestamp": "2016-08-10 19:37:44",
"UserLastLogin": "1470850664",
"UserMarkTicketUnseenRedirectURL": "Action=AgentTicketZoom;TicketID=###TicketID####1",
"AdminDynamicFieldsOverviewPageShown": "35",
"UserChangeOverviewSmallPageShown": "25",
"RoleIDs": [],
"ValidID": "1",
"UserStoredFilterColumns-AgentTicketQueue": "{}",
"UserEmail": "ROOT@loCalhosT",
"UserRefreshTime": "0",
"UserDashboardPref0130-TicketOpen-Shown": "10",
"UserTicketOverviewAgentTicketQueue": "Small",
"UserID": "1",
"UserDashboardTicketGenericColumnFiltersRealKeys0120-TicketNew": "{\"QueueIDs\":[\"1\"]}",
"wpt22": "1",
"UserMarkTicketSeenRedirectURL": "Action=AgentTicketZoom;TicketID=###TicketID####1",
"UserStoredFilterColumns-AgentTicketEscalationView": "{}",
"UserDashboardTicketGenericFilter0120-TicketNew": "MyQueues",
"UserCreateNextMask": "",
"UserFirstname": "Admin",
"UserPw": "9faaba2ab242a99bbb6992e9424386375f6757c17e6484ae570f39d9cad9f28ea",
"UserDashboardPref0110-TicketEscalation-Shown": "10",
"UserFilterColumnsEnabled-AgentTicketQueue": "[\"TicketNumber\",\"Age\",\"Title\",\"State\",\"Lock\",\"DynamicField_CustomerLocation\",\"Queue\",\"Owner\",\"CustomerID\",\"DynamicField_Hostname\"]",
"OutOfOfficeEndMonth": "9",
"ChangeTime": "2014-04-28 10:53:18",
"UserDashboardPref0130-TicketOpen-Columns": "{\"Columns\":{\"Changed\":0,\"CustomerID\":0,\"CustomerUserID\":0,\"EscalationResponseTime\":0,\"EscalationTime\":0,\"EscalationUpdateTime\":0,\"Lock\":0,\"Owner\":0,\"PendingTime\":0,\"Priority\":0,\"Queue\":0,\"Responsible\":0,\"SLA\":0,\"Service\":0,\"State\":0,\"Type\":0,\"Age\":1,\"DynamicField_CustomerLocation\":1,\"Title\":1,\"CustomerName\":1,\"EscalationSolutionTime\":1,\"TicketNumber\":1},\"Order\":[\"Age\",\"DynamicField_CustomerLocation\",\"Title\",\"CustomerName\",\"EscalationSolutionTime\",\"TicketNumber\"]}",
"UserTicketOverviewAgentTicketSearch": "Small",
"UserTicketOverviewAgentCustomerSearch": "Small",
"UserDashboardTicketGenericColumnFilters0120-TicketNew": "{\"Queue\":\"1\"}",
"GroupIDs": {
"6": [
"ro",
"move_into",
"create",
"note",
"owner",
"priority",
"rw"
],
"3": [
"ro",
"move_into",
"create",
"note",
"owner",
"priority",
"rw"
],
"7": [
"ro",
"move_into",
"create",
"note",
"owner",
"priority",
"rw"
],
"2": [
"ro",
"move_into",
"create",
"note",
"owner",
"priority",
"rw"
],
"8": [
"ro",
"move_into",
"create",
"note",
"owner",
"priority",
"rw"
],
"1": [
"ro",
"move_into",
"create",
"note",
"owner",
"priority",
"rw"
],
"4": [
"ro",
"move_into",
"create",
"note",
"owner",
"priority",
"rw"
],
"5": [
"ro",
"move_into",
"create",
"note",
"owner",
"priority",
"rw"
]
},
"UserConfigItemOverviewSmallPageShown": "25",
"UserAuthBackend": "",
"UserTicketOverviewAgentTicketLockedView": "Small",
"UserTicketOverviewAgentTicketEscalationView": "Small",
"UserTicketOverviewAgentTicketStatusView": "Small",
"UserLoginFailed": "0"
}

View file

@ -158,4 +158,42 @@ RSpec.describe Import::OTRS::CustomerUser do
updates_with(zammad_structure) updates_with(zammad_structure)
end end
end end
context 'regular user with camelcase login' do
let(:object_structure) { load_customer_json('camel_case_login') }
let(:zammad_structure) do
{
created_by_id: '1',
updated_by_id: '1',
active: true,
source: 'OTRS Import',
organization_id: 1337,
role_ids: [3],
updated_at: '2014-06-07 02:31:31',
created_at: '2014-06-07 02:31:31',
note: '',
email: 'qa100@t-online.de',
firstname: 'test669673',
lastname: 'test669673',
login: 'test669673',
password: 'f8be19af2f25837a31eff9131b0e47a5173290652c04a48b49b86474d48825ee',
phone: nil,
fax: nil,
mobile: nil,
street: nil,
zip: nil,
city: nil,
country: nil
}
end
it 'creates' do
creates_with(zammad_structure)
end
it 'updates' do
updates_with(zammad_structure)
end
end
end end

View file

@ -166,4 +166,38 @@ RSpec.describe Import::OTRS::User do
updates_with(zammad_structure) updates_with(zammad_structure)
end end
end end
context 'regular user with camel case login' do
let(:object_structure) { load_user_json('camel_case_login') }
let(:zammad_structure) do
{
created_by_id: 1,
updated_by_id: 1,
active: true,
source: 'OTRS Import',
role_ids: [2, 1],
group_ids: ['1'],
password: '{sha2}9faaba2ab242a99bbb6992e9424386375f6757c17e6484ae570f39d9cad9f28ea',
updated_at: '2014-04-28 10:53:18',
created_at: '2014-04-28 10:53:18',
id: '1',
email: 'root@localhost',
firstname: 'Admin',
lastname: 'OTRS',
login: 'root@localhost'
}
end
it 'creates' do
prepare_expectations
creates_with(zammad_structure)
end
it 'updates' do
prepare_expectations
updates_with(zammad_structure)
end
end
end end