From d20593329ee6a2253aaa989f96811112708916fc Mon Sep 17 00:00:00 2001 From: dewmini <5234594+dewmini@users.noreply.github.com> Date: Thu, 27 Jul 2023 08:38:50 +1000 Subject: [PATCH 1/6] Fix #169 --- .../au/org/ala/userdetails/PropertyController.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grails-app/controllers/au/org/ala/userdetails/PropertyController.groovy b/grails-app/controllers/au/org/ala/userdetails/PropertyController.groovy index 2e28a43f..6ffd14b1 100644 --- a/grails-app/controllers/au/org/ala/userdetails/PropertyController.groovy +++ b/grails-app/controllers/au/org/ala/userdetails/PropertyController.groovy @@ -89,7 +89,7 @@ class PropertyController extends BaseController { ) @Path("getProperty") @Produces("application/json") - @PreAuthorise(requiredScope = 'users/read') + @PreAuthorise(requiredScope = 'users/read', requiredRole = '') def getProperty() { String name = params.name Long alaId = params.long('alaId') @@ -166,7 +166,7 @@ class PropertyController extends BaseController { ) @Path("saveProperty") @Produces("application/json") - @PreAuthorise(requiredScope = 'users/write') + @PreAuthorise(requiredScope = 'users/write', requiredRole = '') def saveProperty(){ String name = params.name; String value = params.value; From 0ec2c52433d6d6175b2ed80669ec108c61df263a Mon Sep 17 00:00:00 2001 From: dewmini <5234594+dewmini@users.noreply.github.com> Date: Thu, 27 Jul 2023 08:41:50 +1000 Subject: [PATCH 2/6] Update travis config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 97aa62e4..6422f6b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ branches: only: - dev - master - - hotfix + - /^hotfix.*$/ - grails3 - experimental_jwt - /^feature.*$/ From 99abd5e4cd2959e20f85b803338063acc47f81c4 Mon Sep 17 00:00:00 2001 From: dewmini <5234594+dewmini@users.noreply.github.com> Date: Thu, 27 Jul 2023 10:52:50 +1000 Subject: [PATCH 3/6] Add test cases #169 --- .../userdetails/PropertyControllerSpec.groovy | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/test/groovy/au/org/ala/userdetails/PropertyControllerSpec.groovy diff --git a/src/test/groovy/au/org/ala/userdetails/PropertyControllerSpec.groovy b/src/test/groovy/au/org/ala/userdetails/PropertyControllerSpec.groovy new file mode 100644 index 00000000..df688edf --- /dev/null +++ b/src/test/groovy/au/org/ala/userdetails/PropertyControllerSpec.groovy @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2022 Atlas of Living Australia + * All Rights Reserved. + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + */ + +package au.org.ala.userdetails + +import au.org.ala.ws.security.JwtProperties +import grails.converters.JSON +import grails.testing.gorm.DataTest +import grails.testing.web.controllers.ControllerUnitTest + +class PropertyControllerSpec extends UserDetailsSpec implements ControllerUnitTest, DataTest{ + + def profileService = Mock(ProfileService) + + static doWithSpring = { + jwtProperties(JwtProperties) { + enabled = true + fallbackToLegacyBehaviour = true + } + authorisedSystemService(UserDetailsSpec.Authorised) + } + + private User user + + void setupSpec() { + mockDomains(User, Role, UserRole, UserProperty) + } + + void setup() { + registerMarshallers() + user = createUser() + controller.profileService = profileService + } + + void "Get user property"() { + when: + request.method = 'GET' + params.alaId = Long.toString(user.id) + params.name = "prop1" + controller.getProperty() + + then: + 1 * profileService.getUserProperty(user, 'prop1') >> { [ new UserProperty(user: user, name: 'prop1', value: + user.userProperties.find {it.name == "prop1"}.value)] } + + def deserializedJson = JSON.parse(response.text) + deserializedJson[0].name == 'prop1' + deserializedJson[0].value == user.userProperties.find {it.name == "prop1"}.value + } + + void "Save user property"() { + when: + request.method = 'POST' + params.alaId = Long.toString(user.id) + params.name = "city" + params.value = "city" + controller.saveProperty() + + then: + 1 * profileService.saveUserProperty(user, 'city', 'city') >> { new UserProperty(user: user, name: 'city', value:'city') } + + def deserializedJson = JSON.parse(response.text) + deserializedJson.name == 'city' + deserializedJson.value == 'city' + } +} From 5aa6c3a230ed81365a5fc942e873fb227dc25dfb Mon Sep 17 00:00:00 2001 From: dewmini <5234594+dewmini@users.noreply.github.com> Date: Mon, 7 Aug 2023 15:49:22 +1000 Subject: [PATCH 4/6] Release 3.0.3 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 573f4e28..e9207bda 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ plugins { id "com.gorylenko.gradle-git-properties" version "2.4.1" } -version "3.0.2" +version "3.0.3" group "au.org.ala" apply plugin:"eclipse" From 42df06a4b3fcf71ed0f709884f63146765880db9 Mon Sep 17 00:00:00 2001 From: Bruce Hyslop Date: Wed, 29 Nov 2023 14:12:56 +1100 Subject: [PATCH 5/6] #180 use custom character data for symbols (without extra special characters) --- .../services/au/org/ala/userdetails/PasswordService.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grails-app/services/au/org/ala/userdetails/PasswordService.groovy b/grails-app/services/au/org/ala/userdetails/PasswordService.groovy index d64bc933..25f4d977 100644 --- a/grails-app/services/au/org/ala/userdetails/PasswordService.groovy +++ b/grails-app/services/au/org/ala/userdetails/PasswordService.groovy @@ -15,6 +15,7 @@ package au.org.ala.userdetails +import au.org.ala.auth.EnglishCustomCharacterData import au.org.ala.auth.PasswordPolicy import au.org.ala.cas.encoding.BcryptPasswordEncoder import au.org.ala.cas.encoding.LegacyPasswordEncoder @@ -282,7 +283,7 @@ class PasswordService { ruleGroup.rules.add(new CharacterRule(EnglishCharacterData.Digit, policy.charGroupMinDigit)) } if (policy.charGroupMinSpecial > 0) { - ruleGroup.rules.add(new CharacterRule(EnglishCharacterData.Special, policy.charGroupMinSpecial)) + ruleGroup.rules.add(new CharacterRule(EnglishCustomCharacterData.Special, policy.charGroupMinSpecial)) } } From f842565660760e51fcaf3dce1ac43dd3ad596090 Mon Sep 17 00:00:00 2001 From: Bruce Hyslop Date: Wed, 29 Nov 2023 14:42:53 +1100 Subject: [PATCH 6/6] fixed import conflict --- .../services/au/org/ala/userdetails/PasswordService.groovy | 4 ---- 1 file changed, 4 deletions(-) diff --git a/userdetails-plugin/grails-app/services/au/org/ala/userdetails/PasswordService.groovy b/userdetails-plugin/grails-app/services/au/org/ala/userdetails/PasswordService.groovy index 44e4094d..7014f90f 100644 --- a/userdetails-plugin/grails-app/services/au/org/ala/userdetails/PasswordService.groovy +++ b/userdetails-plugin/grails-app/services/au/org/ala/userdetails/PasswordService.groovy @@ -15,13 +15,9 @@ package au.org.ala.userdetails -<<<<<<< HEAD:grails-app/services/au/org/ala/userdetails/PasswordService.groovy import au.org.ala.auth.EnglishCustomCharacterData -======= import au.org.ala.auth.PasswordResetFailedException import au.org.ala.users.IUser -import au.org.ala.users.UserRecord ->>>>>>> epic/cognito/develop:userdetails-plugin/grails-app/services/au/org/ala/userdetails/PasswordService.groovy import au.org.ala.auth.PasswordPolicy import au.org.ala.cas.encoding.BcryptPasswordEncoder import au.org.ala.cas.encoding.LegacyPasswordEncoder