@@ -66,6 +66,7 @@ func TestCreateKeyRSA(t *testing.T) {
6666 })
6767 }
6868}
69+
6970func TestCreateKeyRSATags (t * testing.T ) {
7071 stop := startTest (t )
7172 defer stop ()
@@ -510,9 +511,8 @@ func TestUpdateKeyPropertiesImmutable(t *testing.T) {
510511 },
511512 Operations : []* Operation {to .Ptr (OperationEncrypt ), to .Ptr (OperationDecrypt )},
512513 })
513- _ = err
514- // require.NoError(t, err) // Recently failing with "AKV.SKR.1012: The specified attestation service cannot be reached."
515- // defer cleanUpKey(t, client, key)
514+ require .NoError (t , err )
515+ defer cleanUpKey (t , client , key )
516516
517517 newMarshalledPolicy , err := json .Marshal (map [string ]interface {}{
518518 "anyOf" : []map [string ]interface {}{
@@ -528,19 +528,14 @@ func TestUpdateKeyPropertiesImmutable(t *testing.T) {
528528 "version" : "1.0.0" ,
529529 })
530530 require .NoError (t , err )
531- // require.Nil(t, createResp.Key.Properties)
532- _ = createResp
533- _ = newMarshalledPolicy
534531
535- /*
536- createResp.Key.ReleasePolicy = &ReleasePolicy{
537- Immutable: to.Ptr(true),
538- EncodedPolicy: newMarshalledPolicy,
539- }
540- _, err = client.UpdateKeyProperties(ctx, *createResp.Key, nil)
541- _ = err
542- require.Error(t, err)
543- */
532+ createResp .Key .ReleasePolicy = & ReleasePolicy {
533+ Immutable : to .Ptr (true ),
534+ EncodedPolicy : newMarshalledPolicy ,
535+ }
536+
537+ _ , err = client .UpdateKeyProperties (ctx , createResp .Key , nil )
538+ require .Error (t , err )
544539 })
545540 }
546541}
@@ -694,9 +689,7 @@ func TestGetRandomBytes(t *testing.T) {
694689func TestGetDeletedKey (t * testing.T ) {
695690 for _ , testType := range testTypes {
696691 t .Run (fmt .Sprintf ("%s_%s" , t .Name (), testType ), func (t * testing.T ) {
697- if testType == HSMTEST {
698- t .Skip ()
699- }
692+ skipHSM (t , testType )
700693 stop := startTest (t )
701694 defer stop ()
702695
@@ -727,10 +720,9 @@ func TestGetDeletedKey(t *testing.T) {
727720}
728721
729722func TestRotateKey (t * testing.T ) {
730- t .Skipf ("Skipping while service disabled feature" )
731723 for _ , testType := range testTypes {
732724 t .Run (fmt .Sprintf ("%s_%s" , t .Name (), testType ), func (t * testing.T ) {
733- alwaysSkipHSM (t , testType )
725+ skipHSM (t , testType )
734726 stop := startTest (t )
735727 defer stop ()
736728
@@ -743,6 +735,11 @@ func TestRotateKey(t *testing.T) {
743735 require .NoError (t , err )
744736 defer cleanUpKey (t , client , key )
745737
738+ if testType == HSMTEST {
739+ // MHSM keys don't have a default rotation policy
740+ _ , err = client .UpdateKeyRotationPolicy (ctx , key , RotationPolicy {Attributes : & RotationPolicyAttributes {ExpiresIn : to .Ptr ("P30D" )}}, nil )
741+ require .NoError (t , err )
742+ }
746743 resp , err := client .RotateKey (ctx , key , nil )
747744 require .NoError (t , err )
748745
@@ -751,16 +748,15 @@ func TestRotateKey(t *testing.T) {
751748
752749 invalid , err := client .RotateKey (ctx , "keynonexistent" , nil )
753750 require .Error (t , err )
754- require .Nil (t , invalid .Key )
751+ require .Zero (t , invalid .Key )
755752 })
756753 }
757754}
758755
759756func TestGetKeyRotationPolicy (t * testing.T ) {
760- t .Skipf ("Skipping while service disabled feature" )
761757 for _ , testType := range testTypes {
762758 t .Run (fmt .Sprintf ("%s_%s" , t .Name (), testType ), func (t * testing.T ) {
763- alwaysSkipHSM (t , testType )
759+ skipHSM (t , testType )
764760 stop := startTest (t )
765761 defer stop ()
766762
@@ -780,11 +776,9 @@ func TestGetKeyRotationPolicy(t *testing.T) {
780776}
781777
782778func TestReleaseKey (t * testing.T ) {
783- t .Skip ("key release isn't supported yet" )
784779 for _ , testType := range testTypes {
785780 t .Run (fmt .Sprintf ("%s_%s" , t .Name (), testType ), func (t * testing.T ) {
786- alwaysSkipHSM (t , testType )
787- // t.Skip("Release is not currently not enabled in API Version 7.3-preview")
781+ skipHSM (t , testType )
788782 stop := startTest (t )
789783 defer stop ()
790784
@@ -806,33 +800,29 @@ func TestReleaseKey(t *testing.T) {
806800 t .Skip ("Skipping test in playback" )
807801 }
808802
809- // Issue when deploying HSM as well
810- if _ , ok := os .LookupEnv ("AZURE_MANAGEDHSM_URL" ); ! ok {
811- _ , err = http .DefaultClient .Do (req )
812- require .Error (t , err ) // This URL doesn't exist so this should fail, will pass after 7.4-preview release
813- // require.Equal(t, resp.StatusCode, http.StatusOK)
814- // defer resp.Body.Close()
803+ resp , err := http .DefaultClient .Do (req )
804+ require .NoError (t , err )
805+ require .Equal (t , resp .StatusCode , http .StatusOK )
806+ defer resp .Body .Close ()
815807
816- // type targetResponse struct {
817- // Token string `json:"token"`
818- // }
808+ type targetResponse struct {
809+ Token string `json:"token"`
810+ }
819811
820- // var tR targetResponse
821- // err = json.NewDecoder(resp.Body).Decode(&tR)
822- // require.NoError(t, err)
812+ var tR targetResponse
813+ err = json .NewDecoder (resp .Body ).Decode (& tR )
814+ require .NoError (t , err )
823815
824- _ , err = client .ReleaseKey (ctx , key , "target" , nil )
825- require .Error (t , err )
826- }
816+ _ , err = client .ReleaseKey (ctx , key , "target" , nil )
817+ require .Error (t , err )
827818 })
828819 }
829820}
830821
831822func TestUpdateKeyRotationPolicy (t * testing.T ) {
832- t .Skipf ("Skipping while service disabled feature" )
833823 for _ , testType := range testTypes {
834824 t .Run (fmt .Sprintf ("%s_%s" , t .Name (), testType ), func (t * testing.T ) {
835- alwaysSkipHSM (t , testType )
825+ skipHSM (t , testType )
836826 stop := startTest (t )
837827 defer stop ()
838828
@@ -848,11 +838,11 @@ func TestUpdateKeyRotationPolicy(t *testing.T) {
848838
849839 get , err := client .GetKeyRotationPolicy (ctx , key , nil )
850840 require .NoError (t , err )
851- get .Attributes . ExpiresIn = to .Ptr ("P90D" )
841+ get .Attributes = & RotationPolicyAttributes { ExpiresIn : to .Ptr ("P90D" )}
852842 get .LifetimeActions = []* LifetimeActions {
853843 {
854844 Action : & LifetimeActionsType {
855- Type : to .Ptr (RotationActionNotify ),
845+ Type : to .Ptr (RotationActionRotate ),
856846 },
857847 Trigger : & LifetimeActionsTrigger {
858848 TimeBeforeExpiry : to .Ptr ("P30D" ),
0 commit comments