MAC is generated incorrectly for Aktia because MAC calculation relies that bank returns query parameters in correct order.

Comments

tuutti’s picture

lauriii’s picture

Status: Active » Needs review
lauriii’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
tuutti’s picture

Status: Needs work » Needs review
StatusFileSize
new5.21 KB
lauriii’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

thank you for working on the tests! In general this looks pretty good already. Just some code style / documentation comments.

  1. +++ b/tupas_registration.module
    @@ -335,29 +335,32 @@ function tupas_registration_return_rej($transaction_id = '') {
    +  foreach ($mac_order as $key) {
    

    It would be useful to document here why do we need to set these in specific order

  2. +++ b/tupas_registration.module
    @@ -384,6 +387,27 @@ function tupas_registration_active_session($transaction_id) {
    + * Generate mac hash.
    

    This could be more describive, i.e. "Generates mac hash based on chosen encryption algorithm."

  3. +++ b/tupas_registration.module
    @@ -384,6 +387,27 @@ function tupas_registration_active_session($transaction_id) {
    + * @param $encryption_alg
    + * @param $mac_string
    

    These are missing description as per Drupal documentation coding standards

  4. +++ b/tupas_registration.module
    @@ -384,6 +387,27 @@ function tupas_registration_active_session($transaction_id) {
    + * @return string
    

    There shold be empty line before @return statement

  5. +++ b/tupas_registration.module
    @@ -384,6 +387,27 @@ function tupas_registration_active_session($transaction_id) {
    +function tupas_registration_hash_mac($encryption_alg, $mac_string) {
    

    Could we rename this to "tupas_registration_generate_mac_hash"

  6. +++ b/tupas_registration.module
    @@ -384,6 +387,27 @@ function tupas_registration_active_session($transaction_id) {
    +  if ($encryption_alg == 01) {
    ...
    +  elseif ($encryption_alg == 03) {
    ...
    +  else {
    

    It might be more obvious to transfer this to use switch instead of if

  7. +++ b/tupas_registration.test
    @@ -68,4 +68,56 @@ class TupasRegistrationTests extends DrupalWebTestCase {
    +   * Make sure that mac calculation is same regardless of what order url arguments
    +   * were given.
    

    According to Drupal documentation standards this should be on single line

  8. +++ b/tupas_registration.test
    @@ -68,4 +68,56 @@ class TupasRegistrationTests extends DrupalWebTestCase {
    +  protected function generateBankMac($bank, $transaction_id) {
    

    We should document the parameteres on the docblock

tuutti’s picture

Status: Needs work » Needs review
StatusFileSize
new3.32 KB
new5.57 KB

  • lauriii committed 80463ce on 7.x-1.x
    Issue #2374777 by tuutti: MAC string is not generated in correct order...
lauriii’s picture

Status: Needs review » Fixed

Thanks for the fix & writing the tests!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.