That case generally does not present itself because the person telling you what to pay as salary knows the rules well, applies them with a narrow margin, and is trusted by his superiors. It is rare for these rulings to be overturned - though I assure you it does occasionally happen!
The case with Apple might be different. From what I remember(!) reading last time this was in the news, both the Apple lawyers as well as the Irish tax authority could be expected to know this deal was crossing the line, and proceeded anyway. (Like buying a cheap bike on the street...)
Ireland is well known for these sorts of practices (for example they also double tax dividends against EU regulations). They have been warned to behave before, so yes, they should be punished. As a willing participant, Apple should not go free either, though.